Page 1 of 1

redirect, but wanna keep post variables..

Posted: Fri Sep 12, 2003 11:01 am
by bg
Im writing the form validation portion of an online store, and have run into a problem. When the user clicks the button to go onto the next "step" in the ordering process, it checks the input and if its not correct it redirects them (header("location: ...")) back to the page and spits out the errors with the input. The problem is when you redirect like this all post variables die, im wondering if anyone knows a way or workaround for this? Thanks,

-brian

Posted: Fri Sep 12, 2003 11:21 am
by m3rajk
aside form finding a way to embed the post commands in the redirect, there's no way to keep them as post.
you can change them to get.

Posted: Fri Sep 12, 2003 12:04 pm
by JayBird
you could put all the values in a hidden form, then use javascript to automatically submit the form using POST.

Mark

Posted: Fri Sep 12, 2003 12:39 pm
by Unipus
That or make them session variables.

Posted: Fri Sep 12, 2003 1:01 pm
by JAM
Or us the URI...

Code: Select all

$array = array("foo"=>"bar", "bar"=>"mofo");
$tmp = serialize($array);
header("Location: next.php?info=".$tmp);

// then on next.php, unserialize, and do whatever...

Posted: Sat Sep 13, 2003 5:43 am
by McGruff
Sessions.

Posted: Sat Sep 13, 2003 11:11 am
by PixelMaster
Or use serialize(), convert the resulting string to base64 with base64_encode(), add it to your URL, and then base64_decode() and unserialize() it on the other end ... you can preserve anything but resource handles this way... only downer is that you end up with a big, long, ugly URL.