Jump to content

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/52607-passing-_post-arrays/
Share on other sites

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

 

Link to comment
https://forums.phpfreaks.com/topic/52607-passing-_post-arrays/#findComment-259596
Share on other sites

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>';
?>

Link to comment
https://forums.phpfreaks.com/topic/52607-passing-_post-arrays/#findComment-259604
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.