php 多個submit提交表單 處理方法

高洛峰
發布: 2023-03-04 18:28:02
原創
2658 人瀏覽過

test.php 

<?php 
$test = $_POST[ &#39;test &#39;]; 
echo &#39;12 &#39;; 
echo $test; 
echo $_POST[ &#39;submit1 &#39;]; 
echo $_POST[ &#39;submit2 &#39;]; 
if (isset($_POST[ &#39;submit1 &#39;]) && $_POST[ &#39;submit1 &#39;] == &#39;submit1 &#39;) 
{ 
echo &#39;ok1 &#39;; 

} 
if (isset($_POST[ &#39;submit2 &#39;]) && $_POST[ &#39;submit2 &#39;] == &#39;submit2 &#39;) 
{ 
// echo " <meta http-equiv=refresh content= &#39;0; url=http://localhost:8000/php/index.php &#39;> "; 
// header( "Location:index.php "); 
// break; 
echo &#39;ok2 &#39;; 
} 
?>
登入後複製
<html> 
<head> </head> 
<body> 
<form action= &#39;xajaxtest.php &#39; method= &#39;POST &#39;> 
<input type= &#39;hidden &#39; name= &#39;test &#39; value= &#39;test1 &#39;> 
<input name= &#39;submit1 &#39; type= &#39;submit &#39; value= &#39;submit1 &#39; title= &#39;submit1 &#39;> 
<input name= &#39;submit2 &#39; type= &#39;submit &#39; value= &#39;submit2 &#39; title= &#39;submit2 &#39;> 
</form> 
</body> 
</html> 
为什么 这个测试页面 载入后第一次不传数据? 
echo $_POST[ &#39;submit1 &#39;];echo $_POST[ &#39;submit2 &#39;];都打印空 
之后就好了。这个是什么原因 有没有办法解决? 
方法二: 
<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提交表單 處理方法相關文章請關注PHP中文網!

相關標籤:
來源:php.cn
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板
關於我們 免責聲明 Sitemap
PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!