dougu3988 2012-02-27 03:30 采纳率: 100%
浏览 589
已采纳

将表单数据发送到一个页面,然后是另一个页面?

I'm having a bit of trouble with this one, as basic as it may be. I have a simple form with name, email, comments, etc. that outputs itself to one php page, but I want to have a link that sends it to a second page, for example:

<label for="name">Name:</label><input type="text" name="name" size="20" />

Goes to a second page (second.php) with this code and prints it just fine:

print "<div>Thank you, $name.</p></div>";

But if I try to send $name to a third page (third.php) using similar code it shows up like this:

Thank you, $name.

With the actual variable and not what was stored in $name.

I feel like I'm missing one tiny little thing but I'm not sure what it is. I used this:

$name = $_POST['name'];

To bring it to second.php and this to bring it to third.php:

print 'Click <a href="third.php? name=' . $name . '">here</a> to proceed.';

Just to see if it would get the same information from second.php, but I don't think it works that way. Is there something else I should be doing on the third page? I have a feeling it's something incredibly insignificant but as I'm learning, I just can't quite get a grasp on it.

  • 写回答

4条回答 默认 最新

  • douzhonglong3789 2012-02-27 03:38
    关注

    You can do it this way.

    when you declare

    $name = $_POST['name'];
    

    you can use in a header to pass this variable

    if(isset($_POST['btnname']))
    {
    header('Location: second.php?name='.$name);
    }
    

    The in your second php

    you can get it by this way

     Thank you, <php echo $_GET['name']; ?>
    

    Or if you want it to be available to all pages use session

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

    =D

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

报告相同问题?

悬赏问题

  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料