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

PHP
PHP实时显示输出
php生成缩略图的类代码
php相当简单的分页类
smarty section简介与用法分析
php优化及高效提速问题的实现方法
php下实现在指定目录搜索指定类型文件的函数
PHP base64+gzinflate压缩编码和解码代码
脚本安全的本质_PHP+MYSQL
使用eAccelerator加密PHP程序
PHP注释实例技巧
php 友好URL的实现(吐血推荐)
关于DISCUZ不用通行证登陆得内容介绍
不用mod_rewrite直接用php实现伪静态化页面代码
Cannot modify header information错误解决方法
php获取地址栏信息的代码
php email邮箱正则
php preg_match_all结合str_replace替换内容中所有img
PHP中str_replace函数使用小结
Zend studio for eclipse中使php可以调用mysql相关函数的设置方法
php flush类输出缓冲剖析

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


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-09-13   浏览: 157 ::
收藏到网摘: 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>