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>

相关文章

sphinx增量索引的一个问题

但最近发现增量的总是搜索不到,今天看了下运行日志,有如下提示: [Sun Apr 17 19:30:01.876 2011] [ 3400] WARNING: rotating inde...

php生成唯一数字id的方法汇总

关于生成唯一数字ID的问题,是不是需要使用rand生成一个随机数,然后去数据库查询是否有这个数呢?感觉这样的话有点费时间,有没有其他方法呢? 当然不是,其实有两种方法可以解决。 1....

php计算数组不为空元素个数的方法

复制代码 代码如下: <?php $arr = array( 1=>"11", 2=>"22", 3=>"33", 4=>"" ); print_r(cou...

php inc文件使用的风险和注意事项

数据库使用中需要关注的主要问题之一是访问权限即用户名及密码的暴露。在编程中为了方便,一般都会用一个db.inc文件保存,如:复制代码 代码如下:<?php $db_use...

基于PHP输出缓存(output_buffering)的深入理解

首先明确一下PHP的输出顺序1.打开了php输出缓存: echo,print -> php output_buffring -> server buffering ->...