简体   繁体   中英

PHP submit form causes a 404 in Firefox but works fine in Chrome

I am having issues when a form is submitted instead of a php page being called I get a 404 error.

Both files are in the same directory and I am using PHPStorm as the IDE and Xampp as the php interpreter. Once the submit button is clicked it tries to open the right page: http://localhost:63342/untitled/learn.php BUT that just gives a 404 message. Oddly then if I press enter on that URL it does take me to the php page just fine, which is really confusing. This however is not an issue using Chrome and only happens in Firefox. The code I used is shown below:

Html page:

<!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 page:

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

    <body>
    <?php

    echo "testing this";

    ?>
    </body>

</html>

action attribute of form expects a URL. So try only learn.php or some full url.

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

The URI of a program that processes the form information. This value can be overridden by a formaction attribute on a or element.

. notation is used in command line generally to denote current directory. I am not sure if same can be used in URL.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM