Last active
August 6, 2019 20:55
-
-
Save JulienRAVIA/0c2452d11d3db83417c00b8fe46449d7 to your computer and use it in GitHub Desktop.
Formulaire
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$event = $_GET['id']; | |
$query = $bdd->prepare('SELECT * FROM questions WHERE id_event = :event'); | |
$query->execute(compact('event')); | |
$questions = $query->fetchAll(); | |
?> | |
<form action="traitement.php" method="post"> | |
<?php foreach($questions as $id => $question): ?> | |
<label for="question_<?= $id ?>"><?= $question ?></label> | |
<input type="text" name="questions[<?= $id ?>]" id="questiion_<?= $id ?>"> | |
<?php endforeach; ?> | |
<button type="submit">Envoyer</button> | |
</form> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$reponses = $_POST['questions']; | |
foreach($reponses as $idQuestion => $reponse) { | |
$query = $bdd->prepare('INSERT INTO reponses(id_question, reponse, date) VALUES(:question, :reponse, :date)'); | |
$query->execute([ | |
'question' => $idQuestion, | |
'reponse' => $reponse, | |
'date' => date('Y-m-d') | |
]); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment