当输入用户名和密码为空的时候,需要判断。这时候就用到了校验用户名和密码,这个需要在jsp的前端页面写;有两种方法,一种是用submit提交。一种是用button提交。
本篇文章主要向大家讲述在php中一个多个submit提交表单如何处理(区分不同的表单提交)
test.php
<?php
$test = $_post[ 'test '];
echo '12 ';
echo $test;
echo $_post[ 'submit1 '];
echo $_post[ 'submit2 '];
if (isset($_post[ 'submit1 ']) && $_post[ 'submit1 '] == 'submit1 ')
{
echo 'ok1 ';
}
if (isset($_post[ 'submit2 ']) && $_post[ 'submit2 '] == 'submit2 ')
{
// echo " <meta http-equiv=refresh content= '0; url=http://localhost:8000/php/index.php '> ";
// header( "location:index.php ");
// break;
echo 'ok2 ';
}
?>
代码如下:
<html>
<head> </head>
<body>
<form action= 'xajaxtest.php ' method= 'post '>
<input type= 'hidden ' name= 'test ' value= 'test1 '>
<input name= 'submit1 ' type= 'submit ' value= 'submit1 ' title= 'submit1 '>
<input name= 'submit2 ' type= 'submit ' value= 'submit2 ' title= 'submit2 '>
</form>
</body>
</html>
以上就是php 多个submit提交表单的实例代码的详细内容。