doutuichan2681 2013-04-03 23:36
浏览 8
已采纳

将变量从第一页传递到第三页PHP

I have a drop down list on page one with select code:

print "Select week for season 1:  <select name='Week_select'> <br>";

On page 2 I have

$varWeek=$_POST['Week_select'];

Then another drop down list:

print "Select a team that played season 1and week $varWeek:  <select name='Team_select'><br>";

So far so good and many thanks to all who have gotten me this far.

Now when I go to page 3, I lose $varWeek

I see that I should either use a $_GET or pass it as hidden. I tried $varWeek=$_GET['Week_select']; but that didn't work.

I am unsure how to pass it hidden. Please help me understand a little more. Many thanks in advance

  • 写回答

2条回答 默认 最新

  • doucanshou6998 2013-04-04 00:03
    关注

    A better approach would be to register those variables as session variables. This way they won't show up in the URL and you will be able to access them across several pages. Have a read here:

    http://www.php.net/manual/en/intro.session.php

    You can access/store a session variable like this:

    $_SESSION['varname'] = 'value';
    

    and on another page

    var_dump($_SESSION['varname']);
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 Python turtle 画图
  • ¥15 关于大棚监测的pcb板设计
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
  • ¥15 Vue3地图和异步函数使用
  • ¥15 C++ yoloV5改写遇到的问题
  • ¥20 win11修改中文用户名路径
  • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
  • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计