0

我正在尝试创建三个页面,当在文本框中输入名称并单击按钮到下一页时,它将要求确认输入的名称是否正确并单击下一步按钮转到最后一页. 输入的文本应该从第一页转移或传递到第二页,然后是第三页。我必须在代码中使用“隐藏”、“标题”和“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>
4

1 回答 1

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。

于 2013-10-29T06:46:11.123 回答