php 多个submit提交表单的实例代码

怪我咯
怪我咯 原创
2023-03-13 21:50:01 3492浏览

当输入用户名和密码为空的时候,需要判断。这时候就用到了校验用户名和密码,这个需要在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提交表单的实例代码的详细内容,更多请关注php中文网其它相关文章!

声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn核实处理。