时间:2021-07-01 10:21:17 帮助过:10人阅读
- <br><?php <br>$test = $_POST[ 'test ']; <br>echo '12 '; <br>echo $test; <br>echo $_POST[ 'submit1 ']; <br>echo $_POST[ 'submit2 ']; <br>if (isset($_POST[ 'submit1 ']) && $_POST[ 'submit1 '] == 'submit1 ') <br>{ <br>echo 'ok1 '; <br><br>} <br>if (isset($_POST[ 'submit2 ']) && $_POST[ 'submit2 '] == 'submit2 ') <br>{ <br>// echo " <meta http-equiv=refresh content= '0; url=http://localhost:8000/php/index.php '> "; <br>// header( "Location:index.php "); <br>// break; <br>echo 'ok2 '; <br>} <br>?> <br> <br><br><span><u></u></span> 代码如下:<pre class="brush:php;toolbar:false layui-box layui-code-view layui-code-notepad"><ol class="layui-code-ol"><li><br><html> <br><head> </head> <br><body> <br><form action= 'xajaxtest.php ' method= 'POST '> <br><input type= 'hidden ' name= 'test ' value= 'test1 '> <br><input name= 'submit1 ' type= 'submit ' value= 'submit1 ' title= 'submit1 '> <br><input name= 'submit2 ' type= 'submit ' value= 'submit2 ' title= 'submit2 '> <br></form> <br></body> <br></html> <br>为什么 这个测试页面 载入后第一次不传数据? <br>echo $_POST[ 'submit1 '];echo $_POST[ 'submit2 '];都打印空 <br>之后就好了。这个是什么原因 有没有办法解决? <br>方法二: <br><script language= "JavaScript "><!-- <br><br>function check(){ <br>frm.action = "checkname.php " <br>} <br>function mysubmit() { <br>frm.action = "zhuce.php " <br>} <br>// --></script> <br><form method=post action= " " name= "frm "> <br><input type= "submit " onclick= "check() "> <br><input type= "submit " onclick= "mysubmit() "> <br></form> <br></li><li> </li><li> </li></ol></pre>