Forum Moderators: coopster

Message Too Old, No Replies

Post vars vs Header Location

lost variable between redirected pages

         

riddle0

6:25 pm on Jun 4, 2007 (gmt 0)

10+ Year Member



I've read lots of replies, but nothing has fixed my small problem. Hopefully, somebody can help me.
Scenario:
Page1.php has a form with method=post to join site as buyer or seller as normal, premium or gold membership.
Page2.php has another form with method=post to pick 6/12 month membership price, whether you want recurring billing and Credit Card data.
Page3.php processes the CC transactions from the post data. Everything is comes in fine. In simple terms my code is:
$response1 = curl_exec() //first payment transaction
$response2 = curl_exec() //for the ARB Automatic Recurring Billing.
if($debug) echo $response1 . $response2; //both good
$_POST['x_response'] = $response1 //or 2 or anything
if(!$debug2 )
header("Location: page4.php");
else
header("Location: page4.php?x_response=".$response1);

Page4.php does not get the HTTP_POST_VARS nor the $_POST['x_response'] nor $_REQUEST
Authorize.net shows both transactions as good.
Debug2 shows the response strings on the url (not a good idea to show peoples CC info on address line)
Please help

eelixduppy

9:11 pm on Jun 4, 2007 (gmt 0)



Welcome to WebmasterWorld, riddle0!

Have you considered using sessions [us2.php.net]? Should make your job easier :)

ahmedtheking

9:13 pm on Jun 4, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



So you want to pass all the POST vars to page4 yeah? Best and most secure way to do it is to store it in a DB, even if it's temporary. (this also means that you have a record of your users).

What you then do is pass a unique ID (like DB insert id) through SESSIONS and as the user progresses, their vars can be bought up.

riddle0

3:58 pm on Jun 6, 2007 (gmt 0)

10+ Year Member



Thanks for the quick replies.
I am taking your advise and saving everything to db then header/location to thank you page and take everything back out of db. It just seems like over-kill for one more page call.

I continued testing and reducing my code to below and is still breaks on both localhost and hosting with both IE7 and FF2.

test_CCthankyou.php:


<?php
session_start();
$a_silly_var = "testing";
$_GET['sillyG'] = $a_silly_var;
$_POST['sillyP'] = $a_silly_var;
$_SESSION['sillyS'] = $a_silly_var;
$location = "Test_of_thankyou.php?silly=".$a_silly_var;

header("Location: $location");
exit();
?>


And Test_of_thankyou.php:

<html>
<head>
<title>Test the Thank you page</title>
</head>
<body>
<?php
$test_var = $_POST['sillyP'];
print "_GET TEST = ".$_GET['sillyG']."<br/>";
print "_POST TEST = ".$_POST['sillyP']."<br/>";
print "_SESSION TEST = ".$_SESSION['sillyS']."<br/>";
print "_REQUEST TEST = ".$_REQUEST['silly']."<br/>";
print "TEST_var = ".$test_var."<br/>";
?>
<A HREF="test_CCthankyou.php"><B>Click Here To Retry</B></A>
<BR>
</body>
</html>

Note the address bar has the correct GET param.
I do understand the missing session due to no session_start() in page2 after a header/location (this was a test).
BUT, What I really need to know is:
What happened to $_POST and $_GET?