我想提交一个POST和一个GET表单提交一个按钮。我尝试使用以下的PHP代码:提交GET表单和另一个POST表单有一个按钮
echo "<html>\n<head>\n<title>Params</title>";
echo "<script type='text/javascript'>";
echo "function submitForms(){
document.getElementById('form1').submit();
document.getElementById('form2').submit();
}";
echo "</script>";
echo "</head>";
echo "<body>";
echo "<form action='' method='get' id='form1'>";
echo "<label>First Name </label>";
echo "<input type='text' name='first'><br/>";
echo "<label>Last Name </label>";
echo "<input type='text' name='last'><br/>";
echo "<label>Age </label>";
echo "<input type='text' name='age'><br/>";
echo "<label>Telephone </label>";
echo "<input type='text' name='phone'><br />";
echo "</form>";
echo "<form action='' method='post' id='form2'>";
echo "<label>Username </label>";
echo "<input type='text' name='username'>";
echo "<label>Password </label>";
echo "<input type='password' name='password'>";
echo "</form>";
echo "<input type='submit' value='Send' onclick='submitForms();'>";
echo "</body></html>";
我得到的只是POST PARAMS,而GET请求根本不加载。 我该如何解决这个问题? 在此先感谢。
您可以删除回显和引号,然后使其作为简单的html运行。 – Vagabond 2014-10-12 10:00:21
只要调用'.submit()',页面就会重新加载,脚本的其余部分将停止。进行多次提交的唯一方法是使用AJAX。 – Barmar 2014-10-12 10:02:58
和你需要两者的原因?为什么不使用一个? – Ghost 2014-10-12 10:03:00