2011-11-14 99 views
1

驗證完表單後,我收集以下信息。PHP中未保存複選框值(Codeigniter)

$inscription_parent['tempassword'] = $this->input->post('password'); 
$inscription_parent['matchingPassword'] = $this->input->post('matchingPassword'); 
$inscription_parent['nameUser'] = $this->input->post('nameUser'); 
$inscription_parent['firstNameUser'] = $this->input->post('firstNameUser'); 
$inscription_parent['sexUser'] = $this->input->post('sexUser'); 
$inscription_parent['emailUser'] = $this->input->post('emailUser'); 
$inscription_parent['phoneHomeUser'] = $this->input->post('phoneHomeUser'); 
$inscription_parent['phoneCellUser'] = $this->input->post('phoneCellUser'); 
$inscription_parent['phoneWorkUser'] = $this->input->post('phoneWorkUser'); 
$inscription_parent['workUser'] = $this->input->post('workUser'); 
$inscription_parent['chkAnimation'] = $this->input->post('chkAnimation'); 
$inscription_parent['chkGestion'] = $this->input->post('chkGestion'); 
$inscription_parent['chkAccompagnement'] = $this->input->post('chkAccompagnement'); 
$inscription_parent['chkCouture'] = $this->input->post('chkCouture'); 
$inscription_parent['chkCuisine'] = $this->input->post('chkCuisine'); 
$inscription_parent['chkAutre'] = $this->input->post('chkAutre'); 
$inscription_parent['autreImplication'] = $this->input->post('autreImplication'); 

$this->session->set_userdata($inscription_parent); 

正如您可能已經注意到的,chk命名的變量是變量。其默認值如下: -

<input id="chkAnimation" name="chkAnimation" class="element checkbox" type="checkbox" value="1" /> 
<label class="choice" for="chkAnimation">Animation</label> 
<input id="chkGestion" name="chkGestion" class="element checkbox" type="checkbox" value="2" /> 
<label class="choice" for="chkGestion">Gestion/Comptabilité</label> 
<input id="chkAccompagnement" name="chkAccompagnement" class="element checkbox" type="checkbox" value="3" /> 
<label class="choice" for="chkAccompagnement">Accompagnement (sorties)</label> 
<input id="chkCouture" name="chkCouture" class="element checkbox" type="checkbox" value="4" /> 
<label class="choice" for="chkCouture">Couture, costumes</label> 
<input id="chkCuisine" name="chkCuisine" class="element checkbox" type="checkbox" value="5"/> 
<label class="choice" for="chkCuisine">Cuisine (cuistot)</label> 
<input id="chkAutre" name="chkAutre" class="element checkbox" type="checkbox" value="6"/> 
<label class="choice" for="chkAutre">Autre</label> 

當我提交操作後打印數組的內容,一切都被妥善保存,而不是複選框!不管我檢查還是取消選中哪一個,都將具有:

(chk(variable)=>) 

你能幫忙嗎?

順便說一下,它們在表單標籤內。

+0

您發佈的代碼將正常工作,但是我認爲您必須在代碼執行之前在表單驗證方面做錯了什麼。您可以發佈您的表單驗證代碼嗎? – devrooms

回答

1

問題出在數組填充的代碼中,導致它被覆蓋。無論如何感謝提示。