je suis en train d'insérer les informations d'un utilisateur a la base de données mais lorsque j’exécute toujours il existe un problème dans la requête qui est exécuté dans mysqli_query().
le message d'erreur est: " erreur d'insertion des informations d'utilisateur"
j'en sais pas ou il existe le problème .
code PHP:
le code html:
Code : 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
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66 <?php include("db.php"); session_start(); //récupération de l'id_user $n=mysqli_query($c,"SELECT idUser FROM utilisateur"); while($r=mysqli_fetch_array($n)){ $id_user=$r['idUser']; } mysqli_free_result($n); $dateN =""; if(isset($_POST['bn'])){ //traitement sur le formulaire if(isset($_POST['nom']) && isset($_POST['prenom']) & isset($_POST['annees']) && isset($_POST['mois']) && isset($_POST['mois']) && isset($_POST['jours'])&& isset($_POST['site']) && isset($_POST['login']) && isset($_POST['password']) ){ $n=$_POST['nom']; $p=$_POST['prenom']; $an=$_POST['annees']; $m=$_POST['mois']; $j=$_POST['jours']; $s=$_POST['site']; $lo=$_POST['login']; $pass=$_POST['password']; //$php=$_POST['ph']; /*$C=$_POST['c']; $cpp=$_POST['cpp']; $java=$_POST['java']; $autre=$_POST['au'];*/ if(isset($_POST['categorie'])){ $categ=array(";",$_POST['categorie']); } if(empty($n) || empty($p) || empty($j) || empty($m) || empty($an) || empty($s) || empty($lo) || empty($pass) || empty($categ) || empty($lo)){ echo "<center><strong><font style='color:red;'>il faut remplir tous les champs !!</font><strong></center>"; }else{ $dateN =$an.'-'.$m.'-'.$j; $v=mysqli_query($c,"INSERT INTO utilisateur (nom,prenon,dateNaissance,siteWeb,login,password) VALUES ('$n','$p','$dateN','$s','$lo','$pass')") or die("erreur d'insertion des informations d'utilisateur".mysqli_connect_error()); foreach ($categorie as $value) { mysqli_query($c,"INSERT INTO utilisateurcategorie (idCategorie) VALUES('$value') ") or die("erreur d'insertion des catégorie".mysqli_connect_error()); } header("location:liste_utilisateurs.php?id='.$id_user"); } } } ?>
merci de résoudre ce problème
Code : 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
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108 <html> <head> <title>exercice3</title> <meta charset="utf-8"> </head> <body> <center> <img src="user.png" width="50px" height="50px" />bonjour <br/> vous etes sur la page d'inscription <br/> <p>toute personne qui veut s'incrire <strong>doit remplir</strong> le formulaire suivant: <form method="POST" enctype="multipart/form-data"> <table cellspacing="30%" cellpadding="20%" bgcolor="#CCCCCC" border="2" > <tr> <td colspan="20"><center> <font size="5" color="red"><strong>Formulaire d'incription</strong> </font> </center> </td> </tr> <tr> <td colspan="12">Nom</td> <td><input type="text" name="nom"/></td> </tr> <tr> <td colspan="12">Prémon</td> <td><input type="text" name="prenom"/></td> </tr> <tr> <td colspan="12">Date de naissance</td> <td> jours <input type="text" name="jours" /> mois <input type="text" name="mois"/> <br/><br/> année <input type="text" name="annees"/> </td> </tr> <tr> <td colspan="12">Situation familiale</td> <td><INPUT type="radio" name="choix" value="Célébataire"> Célébataire <INPUT type="radio" name="choix" value="marié"> Marié <INPUT type="radio" name="choix" value="divorcé"> Divorcé</td> </tr> <tr> <td colspan="12">Site web</td> <td><input type="text" name="site" value="http://" /></td> </tr> <tr> <td colspan="12">Login</td> <td><input type="text" name="login"/></td> </tr> <tr> <td colspan="12">Password</td> <td><input type="password" name="password"/></td> </tr> <tr> <td colspan="12">Langages utilisés</td> <td><input type="checkbox" name="c" value="c" /> Langage C <input type="checkbox" name="cpp" value="cplus" /> C++ <input type="checkbox" name="ja" value="java"/> java <input type="checkbox" name="ph" value="php"/> php <input type="checkbox" name="au" value="autres"/> autres </td> </tr> <tr> <td colspan="12">Catégories de new préférés</td> <td><select name="categorie[]" multiple> <?php $r=mysqli_query($c,"SELECT * FROM categorie")or die("erreur d'affichage de la liste Catégories"); while($a=mysqli_fetch_array($r)){ echo'<option value="'.$a['libelleCategorie'].'">'.$a['libelleCategorie'].'</option>'; } ?> </select></td> </tr> <tr> <td colspan="20" > <center> <input type="submit" value="enregistre" name="bn" /> <input type="reset" value="annuler" name="annuler" /> <img src="true.png" width="20px" height="20px"/> </center> </tr> </table> </form> </center> </body> </html>![]()
Partager