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

yipeiwu_com5年前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多态的实现详解

多态性是指相同的操作或函数、过程可作用于多种类型的对象上并获得不同的结果。不同的对象,收到同一消息将可以产生不同的结果,这种现象称为多态性。多态性允许每个对象以适合自身的方式去响应共同的...

WordPress中用于获取及自定义头像图片的PHP脚本详解

get_avatar()(获取头像) get_avatar() 函数用来获取置顶邮箱或者用户的头像代码,在评论列表中非常常用。 这个函数提供一个 get_avatar 过滤器,用来过滤头...

file_get_contents获取不到网页内容的解决方法

复制代码 代码如下: <?php $url = "http://jb51.net/index.html"; $ch = curl_init(); $timeout = 5...

PHP中substr函数字符串截取用法分析

本文实例讲述了PHP中substr函数字符串截取用法。分享给大家供大家参考,具体如下: PHP中substr函数定义如下: substr(string,start,length) 参数说...

PHP实现链表的定义与反转功能示例

本文实例讲述了PHP实现链表的定义与反转功能。分享给大家供大家参考,具体如下: PHP定义链表及添加、移除、遍历等操作: <?php class Node { pr...