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
|
<?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(){
$Nomhotel1=$_POST['nom0'];
$Adresse1=$_POST['nom1'];
$Pays1=$_POST['nom2'];
$Ville1=$_POST['nom3'];
$Téléphone1=$_POST['nom4'];
$Fax1=$_POST['nom5'];
$Catégorie1=$_POST['nom6'];
//On se connecte
require_once("connexion.php");
if (!empty($_POST['nom0']) && !empty($_POST['nom1']) && !empty($_POST['nom2']) && !empty($_POST['nom3']) && !empty($_POST['nom4']) && !empty($_POST['nom5']) && !empty($_POST['nom6']))
{
//On prépare la commande sql d'insertion
$sql = 'INSERT INTO hotel VALUES("'.$Nomhotel1.'","'.$Adresse1.'","'.$Pays1.'","'.$Ville1.'","'.$Téléphone1.'","'.$Fax1.'","'.$Catégorie1.'")';
/*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)*/
mysql_query ($sql) or die ('Erreur SQL !'.$sql.'<br />'.mysql_error());
}
}
}
$obj =new hotel;
$obj->ajouter();
?> |
Partager