doulaozhi6835 2010-07-29 10:58
浏览 19
已采纳

传递两种形式之间的值

Is there any way to pass values between two forms. Let's say, I have two html form.

At Form 1, there's one field called name and submit button.

At Form 2, there's two field called name and email and submit button.

What I want to get is, At form 1, when i fill Form 1 name field and click submit, it will carry me to form 2 and name values that I filled will be inserted at names field of Form 2.

Is that possible to do that ?

If that so, please leave idea or snippets for me.

Thanks.

  • 写回答

2条回答 默认 最新

  • doushi8599 2010-07-29 11:04
    关注

    if the forms are in separated pages, you can populate values in form two using the $_POST arrays:

    page 1

    <form action="page2.php" method="post">
    name <input type="text" name="name" /><br/>
    email <input type="email" name="email" />
    <input type="submit" value="submit"/>
    </form>
    

    At page2.php, grab values comming from $_POST and populate the form with these values:

    <?php
        $name = $_POST['name'];
        $email = $_POST['email'];
    ?>
    <form action="pageX.php" method="post">
    name <input type="text" name="name" value="<?php echo $name;?>"/><br/>
    email <input type="email" name="email" value="<?php echo $email;?>"/>
    <input type="submit" value="submit"/>
    </form>
    

    Obviously you'll need to validate $_POST data in page2.php, but that's another issue...

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)
  • ¥15 keil里为什么main.c定义的函数在it.c调用不了
  • ¥50 切换TabTip键盘的输入法
  • ¥15 可否在不同线程中调用封装数据库操作的类
  • ¥15 微带串馈天线阵列每个阵元宽度计算
  • ¥15 keil的map文件中Image component sizes各项意思
  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
  • ¥15 划分vlan后,链路不通了?
  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据