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

PHP
利用客户端缓存对网站进行优化的原理分析
php生成随机数或者字符串的代码
php include,include_once,require,require_once
php 特殊字符处理函数
php让图片可以下载的代码
网友原创的PHP模板类代码
wiki-shan写的php在线加密的解密程序
php chr() ord()中文截取乱码问题解决方法
php+AJAX传送中文会导致乱码的问题的解决方法
php面向对象的方法重载两种版本比较
在服务端进行目录建立、删除,文件上传、删除的过程的php代码
php递归列出所有文件和目录的代码
php获取某个目录大小的代码
php目录管理函数小结
Zend Guard一些常见问题解答
fleaphp下不确定的多条件查询的巧妙解决方法
PHP下10件你也许并不了解的事情
PHP常用函数小技巧
php5 pdo新改动加载注意事项
php5新改动之短标记启用方法

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


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