Jump to content

Recommended Posts

I'm really not sure how to use this...there doesn't seem to be much documentation here:

http://www.php.net/manual/en/function.http-post-fields.php

and I'm not familiar with this type of function.

 

Could anyone give me a little help?

 

Basically what I'm doing is taking a form, and then taking the values and pushing them into an array, then calculating cost, and then pushing values into an array to send out. Here is the code, as much as I can give at least.

 

<?php
import_request_variables('pg');
if($undefined_quantity) {
	$item_number.= "$undefined_quantity";
	$item_name .= " x $undefined_quantity";
	if($undefined_quantity < 20) {
		$amount = (8.00 * $undefined_quantity);
	}else if ($undefined_quantity > 20 and $undefined_quantity < 100) {
		$amount = (7.50 * $undefined_quantity);
	}else if ($undefined_quantity > 100 and $undefined_quantity < 250) {
		$amount = (7.00 * $undefined_quantity);
	}else if ($undefined_quantity > 250) {
		$amount = (6.25 * $undefined_quantity);
	}else if ($undefined_quantity == 0 or $undefined_quantity < 0) {
		header("Location: order_error.php");
		exit(0);
	}
	$url = "website here";
	$data = array($cmd,$business,$undefined_quantity,$item_name,$item_number,$amount,$currency_code,$lc,$bn);
	http_post_fields($url,$data);
}
?>

 

I guess what I really don't understand is how to use http_post_fields, do I use a header or something?

 

Thanks in advance

Link to comment
https://forums.phpfreaks.com/topic/67977-problem-with-http_post_fields/
Share on other sites

HTTP POST variables: $_POST

Note: Introduced in 4.1.0. In earlier versions, use $HTTP_POST_VARS.

 

An associative array of variables passed to the current script via the HTTP POST method. Automatically global in any scope.

 

This is a 'superglobal', or automatic global, variable. This simply means that it is available in all scopes throughout a script. You don't need to do a global $_POST; to access it within functions or methods, as you do with $HTTP_POST_VARS.

 

$HTTP_POST_VARS contains the same initial information, but is not a superglobal. (Note that $HTTP_POST_VARS and $_POST are different variables and that PHP handles them as such)

 

If the register_globals directive is set, then these variables will also be made available in the global scope of the script; i.e., separate from the $_POST and $HTTP_POST_VARS arrays. For related information, see the security chapter titled Using Register Globals. These individual globals are not superglobals.

 

import_request_variables is a pre-defined function though php to basically pass the variables from the form to the script, granted if global variables is on you don't need it.

 

could you please provide the link so that I can see some examples of how to use this function? I currently have an error:

 

Fatal error: Function name must be a string in "file" on line 20

Ah, ty. But I don't think that is what I am looking for. The import_request_variables makes sure I have all of the variables as they are defined in the table. However, what I need to do with these variables is send them somewhere else so that it may process the variables. Basically it's going to paypal. But I need to define the price so that's why the form goes here so that it can calculate the final price and then send it.

 

i could be mistaken but that's what it seems this function is doing. i could totally be in the wrong neighborhood too with my original direction.

 

thanks for any help :)

found your problem and fix it for you.

 

<?php
$data = (array($cmd,$business,$undefined_quantity,$item_name,$item_number,$amount,$currency_code,$lc,$bn));?>

 

also it cant be a variable if arrayed. it has to be a string like 'quantity'

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.