1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
| if ($_POST['verif'] > 0 && $_POST['verif'] < 5)
{
$ques = $_POST['ques'];
$reponse1 = htmlentities ($_POST['reponse1'], ENT_QUOTES, 'UTF-8');
$reponse2 = htmlentities ($_POST['reponse2'], ENT_QUOTES, 'UTF-8');
$reponse3 = htmlentities ($_POST['reponse3'], ENT_QUOTES, 'UTF-8');
$reponse4 = htmlentities ($_POST['reponse4'], ENT_QUOTES, 'UTF-8');
$verif = htmlentities ($_POST['verif'], ENT_QUOTES, 'UTF-8');
$reponse = array ($reponse1, $reponse2, $reponse3, $reponse4);
for ($i=0;$i<4;$i++)
{
if ($i == $verif - 1)
{
$reqEcrire = $bdd->prepare ('INSERT INTO reponse (numQuestion, numQuizz, textRep, poids) VALUES (:num, :numq ,:texte, \'1\')') or die (print_r ($bdd->errorInfo ()));
$reqEcrire->execute (array ('num' => $ques, 'numq' => $_POST['numq'], 'texte' => $reponse[$i])) or die (print_r ($reqEcrire->errorInfo ()));
$reqEcrire = $bdd->query ('UPDATE question SET reponse = \'1\' WHERE numQuestion = :num') or die (print_r ($bdd->errorInfo ()));
$reqEcrire->execute (array ('num' => $ques)) or die (print_r ($reqEcrire->errorInfo ()));
}
else
{
$reqEcrire = $bdd->prepare ('INSERT INTO reponse (numQuestion, numQuizz, textRep, poids) VALUES (:num, :numq ,:texte, \'0\')') or die (print_r ($bdd->errorInfo ()));
$reqEcrire->execute (array ('num' => $ques, 'numq' => $_POST['numq'], 'texte' => $reponse[$i])) or die (print_r ($reqEcrire->errorInfo ()));
$reqEcrire = $bdd->query ('UPDATE question SET reponse = \'1\' WHERE numQuestion = :num') or die (print_r ($bdd->errorInfo ()));
$reqEcrire->execute (array ('num' => $ques)) or die (print_r ($reqEcrire->errorInfo ()));
}
}
echo 'Réponses ajoutées.'; |