当输入用户名和密码为空的时候,需要判断。这时候就用到了校验用户名和密码,这个需要在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中文网其它相关文章!
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号