Bonjour,
pourriez-vous me dire ou est l'erreur dans ce script qui empêche l'insertion dans la base de données et merci.
Structure de la table `annexes`
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 <?php require('connexion.php'); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Annexes</title> </head> <body> <form id="form1" name="form1" method="post" action=""> <table width="348" border="0"> <tr> <td>Établissement:</td> <td><label> <select name="id_etablissement" id="id_etablissement"> <?php $sql_etablissements="select id_etablissement,libelle from etablissements order by id_etablissement"; $resultat_etablissements=mysql_query($sql_etablissements); while ($liste=mysql_fetch_row($resultat_etablissements)){ echo "<option value='".$liste[0]."'"; echo ">".$liste[1]."</option>"; }if (isset($_POST['id_etablissement'])) $id_etablissement = $_POST['id_etablissement']; ?> </select> </label></td> </tr> <tr> <td>Annexe:</td> <td><label> <input type="text" name="annexe" id="annexe" <?php if(isset($_POST['annexe'])) $annexe = $_POST['annexe']?> /> </label></td> </tr> <tr> <td>Date de création:</td> <td><label> <input type="text" name="date_creation" id="date_creation" <?php if(isset($_POST['date_creation'])) $date_creation = $_POST['date_creation']?> /> <img src="../images/calendar.png" width="16" height="16" /></label></td> </tr> <tr> <td>Tel:</td> <td><label> <input type="text" name="tel" id="tel" <?php if(isset($_POST['tel'])) $tel = $_POST['tel']?>/> </label></td> </tr> <tr> <td>Fax:</td> <td><label> <input type="text" name="fax" id="fax" <?php if(isset($_POST['fax'])) $fax = $_POST['fax']?>/> </label></td> </tr> <tr> <td>Date de fermeture:</td> <td><label> <input type="text" name="date_fermeture" id="date_fermeture" <?php if(isset($_POST['date_fermeture'])) $date_fermeture = $_POST['date_fermeture']?>/> <img src="../images/calendar.png" alt="" width="16" height="16" /></label></td> </tr> <tr> <td> </td> <td><input type="submit" value="Insérer l'enregistrement" /></td> </tr> </table> </form> </body> </html> <?php if (isset($annexe)){ $sql_verifiction = "select * from annexes where annexe = '$annexe'"; $resultat_verification = mysql_query($sql_verifiction); if(mysql_num_rows($resultat_verification)==1) echo "<strong><font color='red'>Annexe existant tapez un autre</font></strong>"; else { $sql_insertion = "insert into annexes values('$id_etablissement','$annexe','$date_creation','$tel','$fax','$date_fermeture')"; $resultat_insertion = mysql_query($sql_insertion); } } mysql_close($connexion); ?>
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10 CREATE TABLE IF NOT EXISTS `annexes` ( `id_annexe` int(10) unsigned NOT NULL AUTO_INCREMENT, `id_etablissement` int(10) unsigned NOT NULL, `annexe` varchar(45) DEFAULT NULL, `date_creation` date DEFAULT NULL, `tel` varchar(45) DEFAULT NULL, `fax` varchar(45) DEFAULT NULL, `date_fermeture` date DEFAULT NULL, PRIMARY KEY (`id_annexe`,`id_etablissement`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
Partager