Bonjour,
je veux inserer les donnees de la formaulaire a la base de donnees ts ca marche sauf la valeur de liste deroulante,je trouve dans le champ de la liste numero 0 voila mon code.
page de la formulaire:
page ajouter.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<!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>site annonce</title> </head> <body> <div> <form action="ajouter_annonce.php" method="post" enctype="multipart/form-data"> <p> <label><strong> Annonce:<br/> <br /> Categorie : </strong> <select name="categorie"> <option>Emploi</option> <option>Stage</option> </select> </label> <label> </label> </p> <p><strong> pays:</strong> <? include('connection.php'); echo'<select size=1 name="nom_pays">'."\n"; echo'<option value="-1">-- pays--</option>'."\n"; $resul=mysql_query("select nom_pays from pays"); while($dat=mysql_fetch_array($resul)){ echo'<option value="'.$dat[0].'">'.$dat['nom_pays']; echo'</option>'."\n"; } echo'</select>'."\n"; mysql_close(); ?> </p> <p><strong> ville:</strong> <? include('connection.php'); echo'<select size=1 name="nom_ville">'."\n"; echo'<option value="-1">-- ville--</option>'."\n"; $result=mysql_query("select nom_ville from ville"); while($data=mysql_fetch_array($result)){ echo'<option value="'.$data[0].'">'.$data['nom_ville']; echo'</option>'."\n"; } echo'</select>'."\n"; mysql_close(); ?> </p> <p><strong> Code postal: </strong> <input type="text" name="code_postal" /> </p> <p> <label><strong> domaine : </strong></label> <? include('connection.php'); echo'<select size=1 name="domaine">'."\n"; echo'<option value="-1">-- domaine--</option>'."\n"; $res=mysql_query("select domaine from domaine"); while($da=mysql_fetch_array($res)){ echo'<option value="'.$da[0].'">'.$da['domaine']; echo'</option>'."\n"; } echo'</select>'."\n"; mysql_close(); ?> </p> <p> <label><strong> fonction : </strong> <? include('connection.php'); echo'<select size=1 name="fonction">'."\n"; echo'<option value="-1">-- fonction--</option>'."\n"; $res=mysql_query("select fonction from fonction"); while($da=mysql_fetch_array($res)){ echo'<option value="'.$da[0].'">'.$da['fonction']; echo'</option>'."\n"; } echo'</select>'."\n"; mysql_close(); ?> </label> </p> <p><strong> Titre annonce : </strong> <input type="text" name="titre_annonce" /> </p> <p><strong> </strong><strong> Description </strong> :</p> <p><strong> </strong><strong> </strong><strong> </strong><strong> </strong><strong> </strong><strong> </strong><strong> </strong><strong> </strong><strong> </strong><strong> </strong><strong> </strong><strong> </strong><strong> </strong> <textarea name="description" cols="45" rows="5"></textarea> </p> <p><strong> </strong><strong> </strong><strong>Raison social : </strong> <input type="text" name="raison_sociale" /> </p> <p> <label><strong> nom : </strong> <strong> </strong><strong> </strong><strong> </strong> <input type="text" name="nom" /> </label> </p> <p><strong> </strong> <input type="hidden" name="id_user" /> </p> <p> <label><strong> Tel : </strong><strong> </strong><strong> </strong><strong> </strong><strong> </strong><strong> </strong><strong> </strong><strong> </strong><strong> </strong><strong> </strong> <input type="text" name="tel" /> </label> </p> <p> <label><strong> </strong></label> <strong>Image:</strong> <strong> </strong><strong> </strong> <input type="file" name="monfichier" /> </p> <p> <label><strong> </strong></label> </p> <p> <input type="submit" name="ok" value="Enregistrer" /> </p> <p> </p> </form> </div> </body> </html>
merci d'avance
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 <? include("connection.php"); if(isset($_POST['titre_annonce'])and isset($_POST['description'])){ $categorie=$_POST['categorie']; $id_ville=$_POST['nom_ville']; $code_postal=$_POST['code_postal']; $id_domaine=$_POST['domaine']; $id_fonction=$_POST['fonction']; $description=$_POST['description']; $titre_annonce=$_POST['titre_annonce']; $raison_sociale=$_POST['raison_sociale']; $nom=$_POST['nom']; $tel=$_POST['tel']; //$valider=$_POST['valider']; $repertoireDestination = "image_annonce/"; $nomDestination = $_FILES["monfichier"]["name"]; if (is_uploaded_file($_FILES["monfichier"]["tmp_name"])) { if (rename($_FILES["monfichier"]["tmp_name"], $repertoireDestination.$nomDestination)) { echo "fichier bien telecharger"; } } else { echo "Le fichier n'a pas été uploadé (trop gros ?)"; } $a= "admin/".$repertoireDestination.$nomDestination; if($description==''){ ?> <script language="JavaScript">alert("Vous devez remplir tous les champs");</script> <? } else { mysql_query("INSERT INTO annonces VALUES ( '', '$categorie', '$id_ville', '$code_postal', '$id_domaine', '$id_fonction','$titre_annonce', '$description','$raison_sociale', '$nom', '$tel','$nomDestination','non')"); echo("l ajout effectuer avec succes");} mysql_close(); } ?>








Répondre avec citation
Partager