sanfly Posted May 23, 2007 Share Posted May 23, 2007 Hi All Im probably overlooking something simple here, but if someone can point me in the right direction I would really appreciate it. I have a form which people fill in, it takes them to a page where the details are all displayed, and they then click on confirm to verify that these details are correct. I thought the easiest thing to do would be to pass the whole post array through the form on the "confirm" page, then just extract it on the next (processing) page However, when I try print_r on the value I assigned to the post array, it just says "Array". My code is below, what have I done wrong? At the end of the confirm page: <form method="post" action="booking2.php?action=book3"> <input type="hidden" name="postArray" value="<?=$_POST?>"> <input type="hidden" name="confirmed" value="1"> <input type="Button" onclick="history.back(); return false" value="« EDIT DETAILS"> <input type="submit" value="CONFIRM DETAILS »"> </form> And on the next (processing) page: <?// Get posted variables $postArray = $_POST['postArray']; $confirmed = $_POST['confirmed']; print_r($postArray);?> Quote Link to comment https://forums.phpfreaks.com/topic/52607-passing-_post-arrays/ Share on other sites More sharing options...
sanfly Posted May 23, 2007 Author Share Posted May 23, 2007 I have decided to pass the array as a session instead, but would still be interested in a solution for doing it this way if anyone knows Quote Link to comment https://forums.phpfreaks.com/topic/52607-passing-_post-arrays/#findComment-259589 Share on other sites More sharing options...
pavans Posted May 23, 2007 Share Posted May 23, 2007 http://www.phpquest.com Quote Link to comment https://forums.phpfreaks.com/topic/52607-passing-_post-arrays/#findComment-259592 Share on other sites More sharing options...
sanfly Posted May 23, 2007 Author Share Posted May 23, 2007 Please dont spam in my thread Quote Link to comment https://forums.phpfreaks.com/topic/52607-passing-_post-arrays/#findComment-259593 Share on other sites More sharing options...
Crimpage Posted May 23, 2007 Share Posted May 23, 2007 The problem is in this part on the first page... <input type="hidden" name="postArray" value="<?=$_POST?>"> All that is going to do is show <input type="hidden" name="postArray" value="Array()"> And if you right click on the page and view source, that's what you will see. You cannot pass an array from page to page like that through a form, I'm pretty sure it has to be done through a session. Dave Quote Link to comment https://forums.phpfreaks.com/topic/52607-passing-_post-arrays/#findComment-259596 Share on other sites More sharing options...
sasa Posted May 23, 2007 Share Posted May 23, 2007 try <?php $a = array('"sasa"',2,'xyz\'s',12.33,array('k'=>9,'l'=> 8,'m'=> 7)); $one =array(':\'','\';','"'); $two =array(':"','";','"'); $b = str_replace($two,$one,serialize($a)); if($_POST){ $x = unserialize(str_replace($one,$two,stripslashes($_POST['val_array']))); echo "<pre>"; print_r($x); echo "</pre>"; } echo '<form method="POST"> <input type="hidden" value="'.$b.'" name="val_array"> <input type="submit"> </form>'; ?> Quote Link to comment https://forums.phpfreaks.com/topic/52607-passing-_post-arrays/#findComment-259604 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.