Saving form POST data across form handler and header call

katrine11

New Member
I've been stuck on this problem for a while now and seeking some help. Thanks in advanced. I have a form on a page (guest/build.php) with a bunch of radio buttons:\[code\]<form action="../php/build.php" method="POST"><table class="table"> <caption>Your Computer Parts</caption> <tr><th>General Component</th><th>Specific Component</th><th>Cost</th></tr> <?php include('buildFunction.php');?> </table><input id="buyMe" type="submit" value="http://stackoverflow.com/questions/13709336/BUY ME NOW!!!"> </form>\[/code\]This sends the data from the radio buttons to my form handler(php/build.php) which makes sure everything has been selected:\[code\]<?phpinclude('manageUser.php');$mainCheck = isset($_POST["chasis"]) && isset($_POST["cpu"]) && isset($_POST["mobo"]) && isset($_POST["ram"]) && isset($_POST["gpu"]) && isset($_POST["psu"]) && isset($_POST["hdd"]) && isset($_POST["monitor"]) && isset($_POST["keyboard"]) && isset($_POST["mouse"]);if(!$mainCheck){ redirect("../guest/build.php","Please select 1 of each component");} else { redirect("../user/purchase.php","Items Successfully Added");}?>\[/code\]And my redirect function (php/manageUser.php):\[code\]function redirect($url, $message){session_start();$_SESSION["message"] = $message; //var_dump($_POST); //exit;header("Location: $url");die;\[/code\]OK, so the results of that commented var_dump are exactly what I want:\[code\]array(10) { ["chasis"]=> string(1) "3" ["cpu"]=> string(1) "9" ["mobo"]=> string(2) "13" ["ram"]=> string(2) "18" ["gpu"]=> string(2) "22" ["psu"]=> string(2) "27" ["hdd"]=> string(2) "31" ["monitor"]=> string(2) "38" ["keyboard"]=> string(2) "42" ["mouse"]=> string(2) "47" } }\[/code\]However, as soon as I call the header function, I loose the data in the POST array. I tried saving it into a global variable, but it always registered NULL, and didn't seem proper anyway. My goal is that the ID's of each item stay in the POST array after the redirect, which I can then use to fill out a price table on the next page(user/purchase.php). Am I going about this the wrong way? And if so what is the proper way? I'm trying to stick with PHP at this phase and not use javascript here.
 
Back
Top