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

yipeiwu_com6年前PHP代码库
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>

相关文章

javascript,php获取函数参数对象的代码

例如: 复制代码 代码如下: function say () { alert (arguments[0]+'说:'+arguments[1]); } say ('fanglor','fa...

PHP数组函数知识汇总

本文为大家分享了PHP数组函数基础知识,供大家参考,具体内容如下 数组array是非常重要的数据类型。相对于其他的数据类型,它更像是一种结构,而这种结果构可以存储一系列数值。数组能够在单...

PHP获取二叉树镜像的方法

本文实例讲述了PHP获取二叉树镜像的方法。分享给大家供大家参考,具体如下: 问题 操作给定的二叉树,将其变换为源二叉树的镜像。 解决思路 翻转二叉树,有递归和非递归两种方式,非递归就是使...

提示Trying to clone an uncloneable object of class Imagic的解决

使用网上流传的一个程序实现pdf截图为png,需要使用Imagic扩展。在windows下安装完后提示: Fatal error: Trying to clone an unclonea...

php实现的xml操作类

本文实例讲述了php实现的xml操作类。分享给大家供大家参考,具体如下: <?php /* 使用方法: $test=new xml(); $test->new_x...