j'ai un problème de récupération les values de checkbox pour l'insérer à la BD
voici mon code
Code HTML : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 <form action="insertion.php" method="post"> <h4 class="id">exigences de securite* :</h4> <label class="container2">Confidentialité <input type="checkbox" name="choix[]"> <span class="checkmark"></span> </label> <label class="container2">Intergrité <input type="checkbox" name="choix[]"> <span class="checkmark"></span> </label> <label class="container2">Disponibilité <input type="checkbox" name="choix[]"> <span class="checkmark"></span> </label> <button class="icon-btn add-btn" name="button3"> <i class="fas fa-forward"></i> <div class="btn-txt">insérer</div> </button> </form>
Code PHP : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 <?php include_once 'database.php'; $msg= ''; if (isset($_POST['button3'])){ if (!empty($_POST['choix'])) { header('Location: <a href="http://localhost/menace2.php');" target="_blank">http://localhost/menace2.php');</a> foreach ($_POST['choix'] as $value) { $value = implode(",",$_POST['choix']); $sql = "INSERT INTO menace (exigence) VALUES ('$value')";}} if (mysqli_query($conn, $sql )) { $msg= "insertion"; } else { $msg= "erreur"; } mysqli_close($conn); } ?>
quand je lance l'insertion j'reçu la mot 'on' à la BD
aidez moi svp et merci
Partager