0

我已经在运行 10.6.8 的 mac 桌面上安装了 MAMP。我使用dreamweaver 作为IDE 来开发我的网站。我已经用 php 编写了我的网页,我可以在浏览器中预览它,我可以看到一切,所以服务器和那些东西可以工作。但在我的第一页我有这一行:

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

因此,一旦用户从表单中选择了一个单选按钮并单击提交,它就会将他们带到第二页。我知道它与标题一起进入循环,但由于某种原因它无法重定向到 page2。当我单击一个选项并单击提交时,它会再次转到第 1 页。我认为处理会话的标头重定向的 php.ini 文件可能存在问题,我不知道。我是mac的新手。有谁知道是什么问题?谢谢

4

1 回答 1

0

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.

于 2012-09-11T01:37:31.307 回答