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>

相关文章

PHP 身份验证方面的函数

复制代码 代码如下:<?php // 计算身份证校验码,根据国家标准GB 11643-1999 function idcard_verify_number($idcard_base...

PHP简单获取网站百度搜索和搜狗搜索收录量的方法

PHP简单获取网站百度搜索和搜狗搜索收录量的方法

本文实例讲述了PHP简单获取网站百度搜索和搜狗搜索收录量的方法。分享给大家供大家参考,具体如下: 获取网站百度搜索和搜狗搜索的收录量代码,可以用于获取网站域名在搜索引擎的收录数量,一直想...

用穿越火线快速入门php面向对象

复制代码 代码如下: <?php /* *用穿越火线快速入门php面向对象! *php目前已经成为国内的主流web developer的首选开发语言,其强大的面向对象容易使初学者找...

php实现比较两个文件夹异同的方法

本文实例讲述了php实现比较两个文件夹异同的方法。分享给大家供大家参考。具体分析如下: 要求: 只能使用命令行,比较两个文件夹的不同,包括文件的差异。 思考: 虽然linux下有di...

windows中PHP5.2.14以及apache2.2.16安装配置方法第1/2页

首先下载好需要安装的配置文件1、apache-2.2.162、php-5.2.14-Win32 一、apache配置 apache的安装不说了,安装过程中选择自己想安装的位置,一路nex...