dtmm0148603 2012-09-10 22:03
浏览 42

MAMP PHP Mac OSX标头不起作用

I've installed MAMP on a mac desktop running 10.6.8. I'm using dreamweaver as the IDE to develop my website. I have written my webpage in php, I can preview it in the browser and I can see eveything, so the server and that stuff works. But in my first page i have this line:

session_start();
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    if (!empty($_POST["Reg_type"])) {
        $_SESSION["regtype"]=$_POST["Reg_type"];
        header("Location: Page2.php");
        var_dump($_SERVER);
    }
}

So once the user selects a radio button from the form and clicks submit, it'll take them to the 2nd page. I know that it's going into the loop with the header but for some reason it is unable to redirect to page2. When I click an option and hit submit it just goes to page1 again. I think there might be a problem with the php.ini file dealing with header redirects of sessions, i have no idea. I am a newbie to macs. Does anyone know what the problem could be? Thank you

  • 写回答

1条回答 默认 最新

  • douyinbo3361 2012-09-11 01:37
    关注

    If Dreamweaver auto generated your code, check the line were the form tag is declared. If it looks like:

    <form method="POST" action="">
    

    then page1.php will reload, because it is calling itself. It would likely be cleaner to just change the form tag to

    <form method="POST" action="page2.php"> 
    

    and drop the whole if statement.

    On submit page2.php will be loaded and that script/page will have $_POST['Reg_Type'] available for processing. Then if you need to assign $_POST['Reg_Type'] to a session variable, I would do it on page2.php.

    And BTW, non of the above is exclusive to Mac.

    评论

报告相同问题?

悬赏问题

  • ¥15 在获取boss直聘的聊天的时候只能获取到前40条聊天数据
  • ¥20 关于URL获取的参数,无法执行二选一查询
  • ¥15 液位控制,当液位超过高限时常开触点59闭合,直到液位低于低限时,断开
  • ¥15 marlin编译错误,如何解决?
  • ¥15 有偿四位数,节约算法和扫描算法
  • ¥15 VUE项目怎么运行,系统打不开
  • ¥50 pointpillars等目标检测算法怎么融合注意力机制
  • ¥20 Vs code Mac系统 PHP Debug调试环境配置
  • ¥60 大一项目课,微信小程序
  • ¥15 求视频摘要youtube和ovp数据集