Bonjour je suis entrain de développer une page web sur laquelle il y a un formulaire d'inscription.
Je n'arrive pas à insérer les données depuis mon formulaire alors que :
- J'arrive à lire les données
- J'arrive à supprimer les données
- la connexion à la base MySQL fonctionne
Il y a donc deux pages web : formulaire.php ou se trouve le formulaire et inscription.php qui traite le formulaire.
Si vous pouvez m'aider à trouver ou se trouve le problème...parce que la je désespère...
code source de formulaire.php
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204 <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Inscription à la soirée Trance DJs</title> <link href="styles.css" rel="stylesheet" type="text/css" /> <script language="JavaScript"> <!-- function couleur(obj) { obj.style.backgroundColor = "#FFFFFF"; } function check() { var msg = ""; if (document.inscription.mail.value != "") { indexAroba = document.inscription.mail.value.indexOf('@'); indexPoint = document.inscription.mail.value.indexOf('.'); if ((indexAroba < 0) || (indexPoint < 0)) { document.inscription.mail.style.backgroundColor = "#F3C200"; msg += "Le mail est incorrect\n"; } } else { document.inscription.mail.style.backgroundColor = "#F3C200"; msg += "Veuillez saisir votre mail.\n"; } if (document.inscription.nom.value == "") { msg += "Veuillez saisir votre nom\n"; document.inscription.nom.style.backgroundColor = "#F3C200"; } if (document.inscription.prenom.value == "") { msg += "Veuillez saisir votre prenom\n"; document.inscription.prenom.style.backgroundColor = "#F3C200"; } if (msg == "") return(true); else { alert(msg); return(false); } } //--> </script> <style type="text/css"> <!-- .Style1 {font-family: Georgia, "Times New Roman", Times, serif} .Style2 {color: #FF0000} --> </style> </head> <body> <?php include "config.php"; if (isset($_GET['modifier_inscription'])) // Si on demande de modifier une news { // On récupère les infos de la correspondante $retour = mysql_query('SELECT * FROM inscription WHERE id=' . $_GET['modifier_inscription']); $donnees = mysql_fetch_array($retour); // On place le titre et le contenu dans des variables simples $nom = $donnees['nom']; $prenom = $donnees['prenom']; $mail = $donnees['mail']; $paiment = $donnees['paiement']; $nombre = $donnees['nombre']; $id_inscription = $donnees['id']; // Cette variable va servir pour se souvenir que c'est une modification } else // C'est qu'on rédige une nouvelle news { // Les variables $titre et $contenu sont vides, puisque c'est une nouvelle news $nom = ''; $prenom = ''; $mail = ''; $paiement = ''; $nombre = ''; $id_inscription = 0; // La variable vaut 0, donc on se souviendra que ce n'est pas une modification } ?> <div align="center"> <table width="863" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="34" class="gauche"></td> <td valign="top" bgcolor="#ECEBE2"><table width="796" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="795" height="212" class="header"></td> </tr> </table> <table width="796" border="0" cellpadding="0" cellspacing="0"> <tr> <td><img src="images/boutons.png" width="796" height="30" border="0" usemap="#Map" /></td> </tr> </table> <p> </p> <form name="inscription" method="post" action="inscription.php" enctype="application/x-www-form-urlencoded" onSubmit="return check();"><div align="center"> <table width="600" border="0" cellspacing="0" cellpadding="0"> <tr> <td class="tab_haut"> </td> </tr> <tr> <td class="texte"><p align="center" class="Style1"> Formulaire d'inscription à la soirée </p> <p class="Style1"> </p> <blockquote> <p align="left" class="Style1">Nom : <input type="text" name="nom" value="<?php echo $nom; ?>" onkeyup="javascript:couleur(this);" /> <br /> <br /> Prénom : <input type="text" name="prenom" value="<?php echo $prenom; ?>" onkeyup="javascript:couleur(this);" /> <br /> <br /> Adresse mail valide : <input type="text" name="mail" value="<?php echo $mail; ?>" onkeyup="javascript:couleur(this);" /> <br /> <br /> Nombre de personne ( vous y compris ) : <select name="nombre" value="<?php echo $nombre; ?>" > <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> <option value="5">5</option> <option value="6">6</option> <option value="7">7</option> <option value="8">8</option> <option value="9">9</option> </select> </p> <p align="left"><span class="Style1">Méthode de paiement : <select name="paiement" value="<?php echo $paiement; ?>" > <option>Espèce</option> <option>Chèque</option> <option>Paypal</option> <option>Virement bancaire</option> </select> </span><br /> <br /> </p> <blockquote> <p><span class="Style1"> <input type="hidden" name="id_inscription" value="<?php echo $id_inscription; ?>" /> <input type="submit" name="Submit" value="Envoyer" /> <input type="reset" name="Submit2" value="Réinitialiser" /> </span></p> <blockquote> <p align="left"> </p> </blockquote> </blockquote> <p align="left"><span class="Style1"> <span class="Style2">/!\ Tous les champs sont obligatoires. /!\</span><br /> <br /> <br /> </span></p> </blockquote></td> </tr> <tr> <td height="8" class="tab_bas"></td> </tr> </table> <p class="Style1"><span class="Style1"><br /> </span><br /> <br /> </p> <blockquote><blockquote><blockquote> </blockquote> </blockquote> </blockquote> </div> </form> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p></td> <td width="34" bordercolor="0" class="droite"> </td> </tr> </table> <br /> <br /> </div> <map name="Map" id="Map"><area shape="rect" coords="531,5,609,20" href="contact.php" target="_parent" /> <area shape="rect" coords="381,4,517,19" href="paypal.php" target="_parent" /> <area shape="rect" coords="274,4,368,20" href="formulaire.php" target="_parent" /> <area shape="rect" coords="202,3,267,21" href="index.php" target="_parent" /> </map></body> </html>
Et voila le code de la page inscription.php
Merci d'avance pour votre aide.
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158 <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Inscription à la soirée Trance DJs</title> <link href="styles.css" rel="stylesheet" type="text/css" /> <style type="text/css"> <!-- .Style1 {font-family: Georgia, "Times New Roman", Times, serif} .Style2 {color: #FF0000} --> </style> </head> <body> <?php include "config.php"; //----------------------------------------------------- // Vérification 1 : est-ce qu'on veut poster une news ? //----------------------------------------------------- if (isset($_POST['nom']) AND isset($_POST['prenom']) AND isset($_POST['mail']) AND isset ($_POST['nombre']) AND isset ($_POST['paiment'])) { $nom = addslashes($_POST['nom']); $prenom = addslashes($_POST['prenom']); $mail = addslashes($_POST['mail']); $nombre = addslashes($_POST['nombre']); $paiement = addslashes($_POST['paiement']); // On vérifie si c'est une modification de news ou pas if ($_POST['id_inscription'] == 0) { // Ce n'est pas une modification, on crée une nouvelle entrée dans la table mysql_query("INSERT INTO inscription VALUES('', '" . $nom . "', '" . $prenom . "', '" . $mail . "', '" . $nombre . "', '" . $paiement . "',)"); } else { // C'est une modification, on met juste à jour le titre et le contenu mysql_query("UPDATE inscription SET nom='" . $nom . "', prenom='" . $prenom . "', mail='" . $mail . "', nombre='" . $nombre . "', paiement='" . $paiement . "' WHERE id=" . $_POST['id_inscription']); } } //-------------------------------------------------------- // Vérification 2 : est-ce qu'on veut supprimer une news ? //-------------------------------------------------------- if (isset($_GET['supprimer_inscription'])) // Si on demande de supprimer une news { // Alors on supprime la news correspondante mysql_query('DELETE FROM inscription WHERE id=' . $_GET['supprimer_inscription']); } ?> <div align="center"> <table width="863" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="34" class="gauche"></td> <td valign="top" bgcolor="#ECEBE2"><table width="796" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="795" height="212" class="header"></td> </tr> </table> <table width="796" border="0" cellpadding="0" cellspacing="0"> <tr> <td><table width="796" border="0" cellpadding="0" cellspacing="0"> <tr> <td><img src="images/boutons.png" width="796" height="30" border="0" usemap="#Map" /></td> </tr> </table> <map name="Map" id="Map"> <area shape="rect" coords="531,5,609,20" href="contact.php" target="_parent" /> <area shape="rect" coords="381,4,517,19" href="paypal.php" target="_parent" /> <area shape="rect" coords="274,4,368,20" href="formulaire.php" target="_parent" /> <area shape="rect" coords="202,3,267,21" href="index.php" target="_parent" /> </map> </td> </tr> </table> <br /> <br /> <div align="center"> <p> </p> <table width="600" border="0" cellspacing="0" cellpadding="0"> <tr> <td class="tab_haut"> </td> </tr> <tr> <td class="tab_centre"><p align="center" class="Style1"> </p> <p align="center" class="Style1">Merci pour votre inscription. </p> <p align="center" class="Style1"> </div> </br> </br> <table> <tr> <th>Nom </th> <th>Prénom </th> <th>Nombre </th> <th>Mail </th> </tr> <?php $retour = mysql_query('SELECT * FROM inscription ORDER BY nom')or die(mysql_error()); while ($donnees = mysql_fetch_array($retour)) // On fait une boucle pour lister les news { ?> <tr> <td><?php echo '<a href="formulaire.php?modifier_inscription=' . $donnees['id'] . '">'; ?>Modifier</a></td> <td><?php echo '<a href="inscription.php?supprimer_inscription=' . $donnees['id'] . '">'; ?>Supprimer</a></td> <th><?php echo stripslashes($donnees['nom']); ?> </th> <th><?php echo stripslashes($donnees['prenom']); ?> </th> <th><?php echo stripslashes($donnees['nombre']); ?></th> <th><?php echo stripslashes($donnees['mail']); ?></th> </tr> </table> <?php } // Fin de la boucle qui liste les liens ?> </p></td> </tr> <tr> <td height="8" class="tab_bas"></td> </tr> </table> <p> </p> </div> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p></td> <td width="34" bordercolor="0" class="droite"> </td> </tr> </table> <br /> <br /> </div> </body> </html>
Partager