2014-10-19 65 views
0

我需要保存我的提交表单数据,例如:两个页面的名称... 由于某些原因,$ _POST仅保存“动作”页面的数据,但在操作后无法修改页。 这里是我的代码: HTML(表格):

<html> 
<body> <form name="input" action="staff.php" method="post"> 
     Username: <input type="text" name="Name"> 
     <input type="submit" value="Submit"> 
</form> 
</body> 
</html> 

这里submiting之后的下一个页面,它的工作原理...(staff.php)

​​

好,年龄submiting姓名和年龄后,停止工作......(staff2.php) 下面的代码:

<?php 
session_start(); 
echo "You have choosen". 
$_POST['Name']; //it does't show Name.. Please help! 
$_POST['Age']; // it doesnt't show this either.. 
?> 

请帮帮忙,非常感谢提前! :)

回答

0

,你有一个会话运行将它们作为会话变量。

$_SESSION['name'] = $_POST['name']; 
+0

谢谢.................................... 。 – CODE 2014-10-20 15:40:09

2

很明显,第一页没有错。所以不要改变任何东西。

第二页。该帖子的作品。然后添加一个隐藏的输入来保存它并将其保留在下一个:

<?php 
echo "You have chosen: ". $_POST['Name']; // it shows what you've choosen... 
?> 
<form name="input" action="staff2.php" method="post"> 
Age: <input type="text" name="Age"> 
<input type="hidden" name="Name" value="<?php echo $_POST['Name']; ?>" /> <!-- this one --> 
<input type="submit" value="Submit"> 
</form> 

在第三页也是最后一页。正确地将这些变量:

echo 'You have chosen: <br/>'; 
echo $_POST['Name'] . '<br/>'; // this should carry the hidden input you set on the last page 
echo $_POST['Age']; 
//^^ you forgot the echo 
+0

好的谢谢:)我决定使用session =岗位,而不是,但你可以请告诉我如何以检索这些信息为从MySQL表? – CODE 2014-10-20 15:38:33

+0

@CODE确信男人没有问题我很高兴这有助于 – Ghost 2014-10-20 23:56:56