Hi, I am familiar with $_POST since I use 'POST' method in lot of forms and process them in PHP pages...
But, what is $HTTP_POST_VARS? Is it same as $_POST
Printable View
Hi, I am familiar with $_POST since I use 'POST' method in lot of forms and process them in PHP pages...
But, what is $HTTP_POST_VARS? Is it same as $_POST
That was the PHP 3 way of doing it. Just ignore it; it's old and deprecated.
Yes Forget it and use $_POST[] .
Hi, can I post the values of $_POST to a php page without a form...
when I click on 'submit' in a html form, it posts the name of each input fields and their values to the url mentioned in the 'action' attribute of form tag...
Can I directly post these values to the url without a html form?
yes, using something like curl (which mimics a browser)
Also you can your $_REQUEST instead of $_POST if you like, but like mentioned the $HTTP_POST_VARS is just outdated.
Cheers,
You can also use Ajax to send post values to a php page.
Code:vars.open("POST", "file.php", null);
vars.send(parameters);
isn't there any way in php itself to send some $_POST values to another php page?
When you set up IPN for Paypal, we must post some values to the url mentioned in paypal. I know that I can create a form and give the parameters as names for the input fields. But is there any alternative?
I saw this sample code in paypal which actually posts the value without actually submitting a form, can you explain how it does this without submitting:
// read the post from PayPal system and add 'cmd'
$req = 'cmd=_notify-validate';
foreach ($_POST as $key => $value) {
$value = urlencode(stripslashes($value));
$req .= "&$key=$value";
}
// post back to PayPal system to validate
$header .= "POST /cgi-bin/webscr HTTP/1.0\r\n";
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
$header .= "Content-Length: " . strlen($req) . "\r\n\r\n";
$fp = fsockopen ('ssl://www.paypal.com', 443, $errno, $errstr, 30);
// assign posted variables to local variables
$item_name = $_POST['item_name'];
$item_number = $_POST['item_number'];
$payment_status = $_POST['payment_status'];
$payment_amount = $_POST['mc_gross'];
$payment_currency = $_POST['mc_currency'];
$txn_id = $_POST['txn_id'];
$receiver_email = $_POST['receiver_email'];
$payer_email = $_POST['payer_email'];
if (!$fp) {
// HTTP ERROR
} else {
fputs ($fp, $header . $req);
while (!feof($fp)) {
$res = fgets ($fp, 1024);
if (strcmp ($res, "VERIFIED") == 0) {
// check the payment_status is Completed
// check that txn_id has not been previously processed
// check that receiver_email is your Primary PayPal email
// check that payment_amount/payment_currency are correct
// process payment
}
else if (strcmp ($res, "INVALID") == 0) {
// log for manual investigation
}
}
fclose ($fp);
}
?>
Did you read that post? It is possible to send post data with no forums in PHP, using curl().
When pasting a code, please remember to use [code] tags. That includes [ html ], [ code ], and [ php ].
Yes, I read the post about 'curl'. I looked that up in www.php.net and it seems that I have spend a little time in learning. Also, thanks for letting me know how to insert code in my post.
Now the code that I have pasted, doesn't it actually post the data to paypal url without curl()?
Can u please tell me what does the following line do?
Code:fputs ($fp, $header . $req)
This one basically send the the string which is a combination of $header and $request to the destination to the socket. (Note: This is the same principle as writing to a file). $fp points to a paypal script; you are sending the header info (represented by the $header string) and the post data across.
The header indicates that the incoming data is post data. So basically, you are sending information to paypal.