Message d'erreur sur checkbox
Bonjour.
J'ai un formulaire qui contient entre autre plusieurs checkbox.
Avant d'enregistrer les données, je fais un controle de saisie.
Si tout est OK, aucun problème, par contre si un élément du formulaire n'est pas renseigné (par ex un input type text) j'ai un problème avec lex checkbox
mon fichier :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| //vérifie si un type d'action est sélectionné (page 2)
function est_selectionne_action($option) {
return (isset($_POST['action']) && in_array($option, $_POST['action']));
}
if (isset($_POST['action'])){
$action = implode(",", $_POST['action']);
$message31 = "";
}
else {
$action="";
$message31 = "Page 2, merci de cocher 1 type d'action minimum.";
}
//le formulaire
<input type="checkbox" name="action[]" value="ponctuelle" <?php if(est_selectionne_action("ponctuelle")) { echo 'checked'; } else if(!empty($action)){ if(in_array("ponctuelle",$action)) { echo 'checked'; }} ?> style="margin-left:60px"/>- ponctuelle<br />
<input type="checkbox" name="action[]" value="programme" <?php if(est_selectionne_action("programme")) { echo 'checked'; } else if(!empty($action)){ if(in_array("programme",$action)) { echo 'checked'; }} ?> style="margin-left:60px"/>- inscrite dans un programme<br />
<input type="checkbox" name="action[]" value="interactive" <?php if(est_selectionne_action("interactive")) { echo 'checked'; } else if(!empty($action)){ if(in_array("interactive",$action)) { echo 'checked'; }} ?> style="margin-left:60px"/>- interactive<br />
<input type="checkbox" name="action[]" value="poursuite" <?php if(est_selectionne_action("poursuite")) { echo 'checked'; } else if(!empty($_action)){ if(in_array("poursuite",$action)) { echo 'checked'; }} ?> style="margin-left:60px"/>- appelée à se poursuivre<br />
<input type="checkbox" name="action[]" value="reproductible" <?php if(est_selectionne_action("reproductible")) { echo 'checked'; } else if(!empty($action)){ if(in_array( "reproductible",$action)) { echo 'checked'; }} ?> style="margin-left:60px"/>- reproductible<br />
<input type="checkbox" name="action[]" value="terminee" <?php if(est_selectionne_action("terminee")) { echo 'checked'; } else if(!empty($action)){ if(in_array("terminee",$action)) { echo 'checked'; }} ?> style="margin-left:60px"/>- terminée<br /> |
Si par exemple je coche le premier checkbox voilà le message que j'ai :
Code:
1 2 3
| Warning: in_array(): Wrong datatype for second argument in c:\weblocal\sites\clubeuropeendelasante\prix_sante\appels\formulaire_candidature.php on line 491
style="margin-left:60px"/>- inscrite dans un programme
Warning: in_array(): Wrong datatype for second argument in c:\weblocal\sites\clubeuropeendelasante\prix_sante\appels\formulaire_candidature.php on line 492 |
Merci de me dire comment je peux éviter ce message d'erreur