您可以通过两种不同的动作制作两种形式
<form action="login.php" method="post"> <input type="text" name="user"> <input type="password" name="password"> <input type="submit" value="Login"></form><br /><form action="register.php" method="post"> <input type="text" name="user"> <input type="password" name="password"> <input type="submit" value="Register"></form>
还是这样做
<form action="doStuff.php" method="post"> <input type="text" name="user"> <input type="password" name="password"> <input type="hidden" name="action" value="login"> <input type="submit" value="Login"></form><br /><form action="doStuff.php" method="post"> <input type="text" name="user"> <input type="password" name="password"> <input type="hidden" name="action" value="register"> <input type="submit" value="Register"></form>
然后,您的PHP文件将用作一个switch($ _ POST
[‘action’])…,此外,它们不能同时单击两个链接或同时发出请求,每个提交都是一个单独的请求。
然后,您的PHP将继续执行切换逻辑,或者使用不同的php文件执行登录过程,然后执行注册过程



