欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

PHP中CheckBox多選框上傳失敗的代碼寫法

 更新時(shí)間:2017年02月13日 10:38:10   作者:牛奶貓  
這篇文章主要介紹了PHP中CheckBox多選框上傳失敗的代碼寫法,以及php處理checkbox復(fù)選框表單提交問題,需要的朋友可以參考下

用慣Java和其他語言的時(shí)候,表單上傳只需要checkbox的name相同的時(shí)候就可以上傳了

<input type="checkbox" name="checkbox" value="1"> 選項(xiàng)
<input type="checkbox" name="checkbox" value="2"> 選項(xiàng)
<input type="checkbox" name="checkbox" value="3"> 選項(xiàng)
<input type='button' value='確定' onclick="fun()"/>

但是PHP卻只有在這種情況下,name要寫成數(shù)組形式才能正常表單提交

<input type="checkbox" name="checkbox[]" value="1"> 選項(xiàng)1
<input type="checkbox" name="checkbox[]" value="2"> 選項(xiàng)2
<input type="checkbox" name="checkbox[]" value="3"> 選項(xiàng)3
<input type="checkbox" name="checkbox[]" value="4"> 選項(xiàng)4
<input type="checkbox" name="checkbox[]" value="5"> 選項(xiàng)5
<input type="checkbox" name="checkbox[]" value="6"> 選項(xiàng)6
<input type='button' value='確定' onclick="fun()"/>

下面給大家補(bǔ)充PHP處理Checkbox復(fù)選框表單提交問題

PHP表單提交頁面復(fù)選框的名稱后要加[],這樣在接收頁面才能得到正確的結(jié)果。表單提交后得到的是一個(gè)數(shù)組,然后通過訪問數(shù)組元素得到表單的具體vaule值。得到的checkbox1的值,默認(rèn)有</br>換行。

表單代碼:

<form action="" method="post" name="asp"> 
  復(fù)選框1:<input type="checkbox" name="checkbox1[]" value="1" /> 
  復(fù)選框2:<input type="checkbox" name="checkbox1[]" value="2" /> 
  復(fù)選框3:<input type="checkbox" name="checkbox1[]" value="3" /> 
  <input type="submit" name= "Download" vaue="Download" /> 
 </form> 

PHP處理表單代碼:

<?php 
   if(isset($_POST["Download"])) 
   { 
     foreach($_REQUEST['checkbox1'] as $checkbox1) 
     { 
          echo $checkbox1; 
     } 
   } 
?> 

以上所述是小編給大家介紹的PHP中CheckBox多選框上傳失敗的代碼寫法,希望對(duì)大家有所幫助,如果大家有任何疑問請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)腳本之家網(wǎng)站的支持!

相關(guān)文章

最新評(píng)論