PHP提交表单在Firefox中导致404,但在Chrome中工作正常

时间:2016-06-14 07:59:11

标签: php html forms web phpstorm

我在提交表单而不是调用php页面时遇到问题我收到404错误。

两个文件都在同一个目录中,我使用PHPStorm作为IDE,Xampp作为php解释器。单击提交按钮后,它会尝试打开右侧页面: http://localhost:63342/untitled/learn.php但是只发出404消息。奇怪的是,如果我按下该URL的输入它确实带我到php页面就好了,这真的很混乱。然而,这不是使用Chrome的问题,只发生在Firefox中。我使用的代码如下所示:

Html页面:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Tutorial page</title>
</head>
<body>

<form action="learn.php" method="post">
    <table border="0">
        <tr>
            <td>UserName</td>

            <td align="center"> <input type="text" name="username" size="30"/> </td>
        </tr>
        <tr>
            <td colspan="2" align="center"><input type="submit" value="Submit"/> </td>
        </tr>
    </table>

</form>

</body>

</html>

php页面:

<html>
    <head>
    <title>Information gathered</title>
    </head>

    <body>
    <?php

    echo "testing this";

    ?>
    </body>

</html>

1 个答案:

答案 0 :(得分:0)

action

form属性需要一个网址。因此,请仅尝试learn.php或一些完整的网址。

https://developer.mozilla.org/en-US/docs/Web/HTML/Element/form

  

处理表单信息的程序的URI。这个值   可以被一个或一个的形式属性覆盖   元件。

.表示法通常在命令行中用于表示当前目录。我不确定在URL中是否可以使用相同的内容。

相关问题