PHP中没有保存的复选框值(Codeigniter)

时间:2011-11-14 06:37:09

标签: php codeigniter checkbox

在验证表格后,我收集了以下信息。

$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)=> )

你能帮忙吗?

顺便说一句,它们都在表格标签内。

1 个答案:

答案 0 :(得分:1)

问题出在数组填充周围的代码中,导致它被覆盖。无论如何,谢谢你的提示。