当前位置: 首页 > 图文教程 > 网络编程 > PHP > php 多个submit提交表单 处理方法

PHP
PHP 批量删除 sql语句
PHP 字符串 小常识
phpinfo 系统查看参数函数代码
php split汉字
php 更新数据库中断的解决方法
Windows IIS PHP 5.2 安装与配置方法
Windows Apache2.2.11及Php5.2.9-1的安装与配置方法
phpMyAdmin 安装配置方法和问题解决
Windows PHP5和Apache的安装与配置
PHP 输出简单动态WAP页面
php 分页类 扩展代码
php MsSql server时遇到的中文编码问题
php array_map array_multisort 高效处理多维数组排序
php adodb连接mssql解决乱码问题
C# Assembly类访问程序集信息
PHP 木马攻击防御技巧
PHP 函数语法介绍一
php 变量定义方法
PHP 定界符 使用技巧
纯真IP数据库的应用 IP地址转化成十进制

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


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-09-13   浏览: 118 ::
收藏到网摘: n/a

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>
为什么 这个测试页面 载入后第一次不传数据?
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>