php 多个submit提交表单 处理方法

Nicole ·
更新时间:2024-09-21
· 935 次阅读

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>
为什么 这个测试页面 载入后第一次不传数据?
echo $_POST[ 'submit1 '];echo $_POST[ 'submit2 '];都打印空
之后就好了。这个是什么原因 有没有办法解决?
方法二:
<script language= "JavaScript "><!--
function check(){
frm.action = "checkname.php "
}
function mysubmit() {
frm.action = "zhuce.php "
}
// --></script>
<form method=post action= " " name= "frm ">
<input type= "submit " onclick= "check() ">
<input type= "submit " onclick= "mysubmit() ">
</form>
您可能感兴趣的文章:PHP自动生成表单代码分享php 表单数据的获取代码php中一个完整表单处理实现代码php表单转换textarea换行符的方法php 表单验证实现代码PHP对表单提交特殊字符的过滤和处理方法汇总PHP防止表单重复提交的几种常用方法汇总提交表单后 PHP获取提交内容的实现方法php获取从html表单传递数组的方法PHP Web表单生成器案例分析



表单 方法 submit PHP

需要 登录 后方可回复, 如果你还没有账号请 注册新账号