bonjour, j'ai un problème dans l'insertion des données dans un base mysql à partir de formulaire:
voici le code :
Code php5 : 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
 
<?php
//On se connecte
require_once("connexion.php");
class hotel{
public $Nomhotel;
public $Adresse;
public $Pays;
public $Ville;
public $Téléphone;
public $Fax;
public $Catégorie;
function __construct($Nomhotel,$Adresse,$Pays,$Ville,$Téléphone,$Fax,$Catégorie){
$this->Nomhotel =$Nomhotel;
$this->Adresse =$Adresse;
$this->Pays =$Pays;
$this->Ville =$Ville;
$this->Téléphone =$Téléphone;
$this->Fax =$Fax;
$this->Catégorie =$Catégorie;
}
//On récupère les valeurs entrées par l'utilisateur :
public function ajouter(){
 
 
 
 
//On prépare la commande sql d'insertion
$sql = 'INSERT INTO hotel VALUES("'.$this->Nomhotel.'","'.$this->Adresse.'","'.$this->Pays.'","'.$this->Ville.'","'.$this->Téléphone.'","'.$this->Fax.'","'.$this->Catégorie.'")';
 $result->executerQuery($sql);
/*on lance la commande (mysql_query) et au cas où,
on rédige un petit message d'erreur si la requête ne passe pas (or die)
(Message qui intègrera les causes d'erreur sql)*/
 
 
}
}
if (!empty($_POST['nom0']) && !empty($_POST['nom1']) && !empty($_POST['nom2']) && !empty($_POST['nom3']) && !empty($_POST['nom4']) && !empty($_POST['nom5']) && !empty($_POST['nom6']))
{
$obj =new hotel($_POST['nom0'],$_POST['nom1'],$_POST['nom2'],$_POST['nom3'],$_POST['nom4'],$_POST['nom5'],$_POST['nom6']);
$obj->ajouter();
}
?>
il m'affiche aucune faute mais les données n'insèrent pas dans la base .
voici le code de connexion:
Code php5 : 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
 
<?php
class connexion
{
    private
        $Serveur     = '',
        $Bdd         = '',
        $Identifiant = '',
        $Mdp         = '',
        $Lien        = '';  
 
 
 
/**
* Constructeur de la classe
* Connexion aux serveur de base de donnée et sélection de la base
*
* $Serveur     = L'hôte (ordinateur sur lequel Mysql est installé)
* $Bdd         = Le nom de la base de données
* $Identifiant = Le nom d'utilisateur
* $Mdp         = Le mot de passe
*/ 
    public function __construct($Serveur = 'localhost', $Bdd = 'pfementionnée', $Identifiant = 'root', $Mdp = '') 
       {
            $this->Serveur     = $Serveur;
            $this->Bdd         = $Bdd;
            $this->Identifiant = $Identifiant;
            $this->Mdp         = $Mdp;
 
            $this->Lien=mysql_connect($this->Serveur,$this->Identifiant,$this->Mdp);
 
            if (!$this->Lien ) throw new Erreur ('Erreur de connexion au serveur MySql!!!');                
 
            $Base = mysql_select_db($this->Bdd,$this->Lien);
 
            if (!$Base) throw new Erreur ('Erreur de connexion à la base de donnees!!!');
				else echo "";
       }
}
$obj=new connexion();
?>
voici le code de formulaire:
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
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
 
<html>
	<head>
		<title>séjour</title>
	</head>
		<body bgcolor="black"><center>
			<table background="image2.jpg" width="800" height="800">
				<tr width="100" height="100">
					<td>
					</td>
					<img src="man.jpg" width="200" height="100">
						<form name="form1" action="ajouter.html">
							<button type="button1"><img src="ajouter.jpg" width=100 height=100></button></form>
						<form name="form2" action="modification.html">
							<button type="button2"><img src="modifier.jpg" width=100 height=100></button></form>
						<form name="form3" action="suppression.html">
							<button type="button3"><img src="supprimer.jpg" width=100 height=100></button></form>
					<img src="8.jpg" width="200" height="100">
					<td>
					</td>
				</tr>
				<tr><center>
					<td>
					</td>
				     <td><center>
					 <form action ="ajoutsejourhotel.php" method="POST" ENCTYPE=\"multipart/form-data\">
				     <table width="800" height="800">
				<tr>
						<td>
						 <tr>
						  <td>
						    <font color="white">Nom hotel:</font>
						  </td>
						  <td>
						   <input type="text" name="Nomhotel">
						  </td>
						 </tr>
						 <tr>
						<td>
						 <tr>
						  <td>
						    <font color="white">Adresse:</font>
						  </td>
						  <td>
						    <input name="Adresse" type="text">
						  </td>
						 </tr>
						 <tr>
						<td>
						 <tr>
						  <td>
						    <font color="white">Pays:</font>
						  </td>
						  <td>
						    <input name="Pays" type="text">
						  </td>
						 </tr>
						 <tr>
						<td>
						 <tr>
						  <td>
						    <font color="white">Ville:</font>
						  </td>
						  <td>
						    <input name="Ville" type="text">
						  </td>
						 </tr>
						 <tr>
						  <td>
						    <font color="white">Téléphone:</font>
						  </td>
						  <td>
						    <input name="Téléphone" type="text">
						  </td>
						 </tr>
						 <tr>
						  <td>
						    <font color="white">Fax:</font>
						  </td>
						  <td>
						    <input name="Fax" type="text">
						  </td>
						 </tr>
						 <tr>
						  <td>
						    <font color="white">Catégorie:</font>
						  </td>
						  <td>
						    <input name="Catégorie" type="text">
						  </td>
						 </tr>
						 <tr>
					     <td>
						     <a href="ajouter.html"><img src="précédent1.jpg" width="80" height="80"></a>
						 </td>
						 <td>
						 <center>
						 <a href="admini.html"><img src="accueil.jpg" width="80" height="80"></a>
						 </center>
						 </td>
						<td>
 
						 <button type="button6"><img src="valider.jpg" width="100" height="50"></button><br>
						</td>
					</tr>
			</table></center>
					 </td></center>
					<td>
					</td>
				</center></tr>
			</table></center>
			</form>
					 </td></center>
					<td>
					</td>
				</center></tr>
			</table></center>
 
		</body>
</html>
et merci svp sauvez-moi