我正在尝试创建三个页面,当在文本框中输入名称并单击该按钮到下一页时,它将询问确认输入的名称是否正确并单击下一个按钮转到最后一页。输入的文本应从第一页转移或传递到第二页,然后转移到第三页。我必须在代码中使用“隐藏”以及“标题”以及“POST”。
这是我到目前为止在第一页上的内容:
<? $things = array('one thing', 'two thing'); ?>
<form action= "page1.php" method="POST">
<INPUT TYPE="TEXT" name="textbox">
<input type='hidden' name='secret' value=96>
<input type='hidden' name='stuff' value='<?= urlencode(serialize($things)) ?> ' >
<input type='submit' name='submit_btn'>
</form>
这是我在下一页上的内容:
<?php
echo "Click next if your name is " . $_POST['textbox'];
?>
<form action= "page2.php" method="POST">
<input type='hidden' name='secret' value=96>
<input type='hidden' name='stuff' value='<?= urlencode(serialize($things)) ?> ' >
<input type='submit' name='next' value ="next">
</form>
这就是我在最后一页上得到的...请帮忙!谢谢!
<!--
To change this template, choose Tools | Templates
and open the template in the editor.
-->
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title></title>
</head>
<body>
<form action= "page1.php" method="POST">
<?php
echo "Finally! Welcome " . $_POST['textbox'];
?>
</form>
</body>
</html>
答案 0 :(得分:1)
如果没有要发送的输入,为什么在最后一页上有表格?
此外,第一行应该是:
<?php $things = array('one thing', 'two thing');?>
应该是:
<?php $things = array('one thing', 'two thing'); ?>
<form action= "page1.php" method="POST">
<INPUT TYPE="TEXT" name="textbox">
<input type='hidden' name='secret' value=96>
<input type='hidden' name='stuff' value='<?= urlencode(serialize($things)) ?> ' >
<input type='submit' name='submit_btn'>
</form>
<强> page1.php中强>
<!--
To change this template, choose Tools | Templates
and open the template in the editor.
-->
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title></title>
</head>
<body>
<?php
echo "Finally! Welcome " . $_POST['textbox'];
?>
</body>
</html>
HTH。