首页 > 资讯列表 > 编程/数据库 >> PHP

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

PHP 2014-12-10 09:03:09 转载来源: 网络整理/侵权必删

本文为大家讲解了php如何处理多个submit提交的表单数据:如何分辨是哪个表单 提交数据了,感兴趣的同学参考下. 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 ') { // e

本文为大家讲解了php如何处理多个submit提交表单数据:如何分辨是哪个表单 提交数据了,感兴趣的同学参考下.

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>

 

 


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


声明:本文内容来源自网络,文字、图片等素材版权属于原作者,平台转载素材出于传递更多信息,文章内容仅供参考与学习,切勿作为商业目的使用。如果侵害了您的合法权益,请您及时与我们联系,我们会在第一时间进行处理!我们尊重版权,也致力于保护版权,站搜网感谢您的分享!

站长搜索

http://www.adminso.com

Copyright @ 2007~2024 All Rights Reserved.

Powered By 站长搜索

打开手机扫描上面的二维码打开手机版


使用手机软件扫描微信二维码

关注我们可获取更多热点资讯

站长搜索目录系统技术支持