je vous explique, j' ais 10 questions affiché à l'écran avec ce message d'erreur "Undefined index: chx_9" et quand je valide j'ai ce message "null, veuillez remplir tous les champs ", pourquoi?(je suis débutant et j'essaye de comprendre avec votre aide). merci
<?php
if (isset($_POST['correction']))
{
$reponses = array(
'chx' => array(
'reponse' => 'une',
'mot' => 'route'
) ,
'chx_1' => array(
'reponse' => 'un',
'mot' => 'four'
) ,
'chx_2' => array(
'reponse' => 'un',
'mot' => 'bouton'
) ,
'chx_3' => array(
'reponse' => 'un',
'mot' => 'jour'
) ,
'chx_4' => array(
'reponse' => 'une',
'mot' => 'poubelle'
) ,
'chx_5' => array(
'reponse' => 'un',
'mot' => 'nouveau'
) ,
'chx_6' => array(
'reponse' => 'un',
'mot' => 'trou'
) ,
'chx_7' => array(
'reponse' => 'une',
'mot' => 'nouvelle'
) ,
'chx_8' => array(
'reponse' => 'un',
'mot' => 'tournevis'
) ,
'chx_9' => array(
'reponse' => 'une',
'mot' => 'douche'
)
);
foreach($reponses as $cle => $reponse)
{
$choix = array(
'un' => 'un',
'une' => 'une'
);
foreach($choix as $key => $value_choix)
{
echo '<p><input type="checkbox" name="' . $cle . '" value="' . $value_choix . '" />' . $key . '</p>';
}
echo '<p></p><p><b>' . $reponse['mot'] . '</b></p><br />';
}
$cle = $_POST[$cle];
if (empty($cle))
{
var_dump($cle);
$msg = '<p>veuillez remplir tous les champs</p>';
echo $msg;
}
else{
echo $cle;
}
}
?>