Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: $_POST and $HTTP_POST_VARS

  1. #1
    Join Date
    Mar 2009
    Location
    Chennai, India
    Posts
    77
    Thanks
    16
    Thanked 7 Times in 6 Posts

    Default $_POST and $HTTP_POST_VARS

    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

  2. #2
    Join Date
    Jul 2008
    Posts
    199
    Thanks
    6
    Thanked 58 Times in 57 Posts

    Default

    That was the PHP 3 way of doing it. Just ignore it; it's old and deprecated.
    Last edited by Twey; 03-27-2009 at 11:47 AM.

  3. The Following User Says Thank You to techietim For This Useful Post:

    borris83 (03-30-2009)

  4. #3
    Join Date
    Mar 2009
    Location
    Egypt
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Yes Forget it and use $_POST[] .

  5. #4
    Join Date
    Mar 2009
    Location
    Chennai, India
    Posts
    77
    Thanks
    16
    Thanked 7 Times in 6 Posts

    Default Is there any way to post to an url without a form

    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?

  6. #5
    Join Date
    Mar 2009
    Location
    Florida
    Posts
    31
    Thanks
    1
    Thanked 2 Times in 2 Posts

    Default

    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,

  7. The Following User Says Thank You to Lpe04 For This Useful Post:

    borris83 (03-30-2009)

  8. #6
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    You can also use Ajax to send post values to a php page.

    Code:
    vars.open("POST", "file.php", null);
    vars.send(parameters);
    Jeremy | jfein.net

  9. The Following User Says Thank You to Nile For This Useful Post:

    borris83 (03-30-2009)

  10. #7
    Join Date
    Mar 2009
    Location
    Chennai, India
    Posts
    77
    Thanks
    16
    Thanked 7 Times in 6 Posts

    Default

    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);
    }
    ?>

  11. #8
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    Quote Originally Posted by Lpe04 View Post
    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,
    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 ].
    Jeremy | jfein.net

  12. #9
    Join Date
    Mar 2009
    Location
    Chennai, India
    Posts
    77
    Thanks
    16
    Thanked 7 Times in 6 Posts

    Default

    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)

  13. #10
    Join Date
    Mar 2009
    Posts
    65
    Thanks
    13
    Thanked 4 Times in 4 Posts

    Default

    Quote Originally Posted by borris83 View Post
    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);

    ..snipped...
    That is using sockets. Not that whether cURL is better than sockets, just that when using sockets you have to write the headers correctly, which can be a pain, while cURL just let you set options - lots of them - which is just another pain.

  14. The Following User Says Thank You to CrazyChop For This Useful Post:

    borris83 (03-30-2009)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •