Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
362 views
in Technique[技术] by (71.8m points)

php - Where does the form submit to if there is no action specified?

Here is the form that is confusing me

<h1>
    Login
</h1>
<form action="" method="post">
    <table align="left" border="0" cellspacing="0" cellpadding="3">
        <tr>
            <td>
                Username:
            </td>
            <td>
                <input type="text" name="user" maxlength="30">
            </td>
        </tr>
        <tr>
            <td>
                Password:
            </td>
            <td>
                <input type="password" name="pass" maxlength="30">
            </td>
        </tr>
        <tr>
            <td colspan="2" align="left">
                <input type="checkbox" name="remember">
                <font size="2">
                    Remember me next time
            </td>
        </tr>
        <tr>
            <td colspan="2" align="right">
                <input type="submit" name="sublogin" value="Login">
            </td>
        </tr>
        <tr>
            <td colspan="2" align="left">
                <a href="register.php">Join</a>
            </td>
        </tr>
    </table>
</form>

I got the code from this tutorial and it works fine but i cant seem to understand where a/the form submit too if no action is present

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

If action is set to "" or if the action attribute is missing, the form submits to itself. That is, if your script is index.php, your form submits to index.php.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...