Erreur sur validation de checkbox
Encore moi.
Cette fois c'est un problème de checkbox.
Dans mon fichier fonctions.php
Code:
1 2 3 4 5 6 7 8 9 10 11 12
| //vérifie si un type d'action est sélectionné (page 2)
function est_selectionne_action($option) {
if (!isset($_POST['action'])) {
return FALSE;
}
for ($i = 0, $c = count($_POST['action']); $i < $c; $i++) {
if ($_POST['action'][$i] == $option) {
return TRUE;
}
}
return FALSE;
} |
dans mon fichier dossier_candidature.php
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| $action = "";
if (isset($_POST['action'])){
for ($i = 0, $c = count($_POST['action']); $i < $c; $i++) {
$action .= "" . $_POST['action'][$i] . ",";
}
$action= substr($action,0,strlen($action)-1);
}
else {
$action="";
}
?>
<td>
<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 />
</td> |
Je ne vois pas pourquoi j'obtiens ce message d'erreur quand une case n'est pas coché.
Code:
1 2
| Warning: in_array(): Wrong datatype for second argument in c:\weblocal\sites\clubeuropeendelasante\prix_sante\appels\formulaire_candidature.php on line 569
style="margin-left:60px"/>- interactive |
J'avais déjà utilisé tout ça por un autre site et ça marchait.