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

PHP
php zlib压缩和解压缩swf文件的代码
PHP 常用函数库和一些实用小技巧
php 时间计算问题小结
php 禁止页面缓存输出
PHP 地址栏信息的获取代码
据说是雅虎的一份PHP面试题附答案
PHP setcookie() cannot modify header information 的解决方法
Google PR查询接口checksum新算法
php zend 相对路径问题
php mssql 时间格式问题
php str_pad 函数使用详解
php strtotime 函数UNIX时间戳
php array_intersect()函数使用代码
PHP mkdir()定义和用法
php array_flip() 删除数组重复元素
php完全过滤HTML,JS,CSS等标签
php 删除数组元素
PHP $_SERVER详解
php 动态多文件上传
防止MySQL注入或HTML表单滥用的PHP程序

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


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