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条)

报告相同问题?

悬赏问题

  • ¥15 求学软件的前人们指明方向🥺
  • ¥50 如何增强飞上天的树莓派的热点信号强度,以使得笔记本可以在地面实现远程桌面连接
  • ¥15 MCNP里如何定义多个源?
  • ¥20 双层网络上信息-疾病传播
  • ¥50 paddlepaddle pinn
  • ¥20 idea运行测试代码报错问题
  • ¥15 网络监控:网络故障告警通知
  • ¥15 django项目运行报编码错误
  • ¥15 STM32驱动继电器
  • ¥15 Windows server update services