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
| <?php
$nom=$_POST["nom"];
$passwd=$_POST["passwd"];
$db = mysql_connect("localhost", $nom, $passwd);
mysql_select_db("boulangerie",$db);
$n_client=$_POST["n_client"];
$raison_sociale=$_POST["raison_sociale"];
$adresse=$_POST["adresse"];
$ville=$_POST["ville"];
$code_postal=$_POST["code_postal"];
$telephone=$_POST["telephone"];
$code_categorie=$_POST["code_categorie"];
$reponse = "SELECT n_client FROM Clients WHERE n_client='".$n_client."'";
mysql_query($reponse) or die("ERR : " . mysql_error() . "<br />SQL = ". $reponse);
$nb=mysql_num_rows ($reponse);
if($nb!=0)
{
echo "Ce numero client est deja attribué.";
}
else {
$reponse2 = "INSERT INTO boulangerie.Clients(n_client,raison_sociale,adresse,ville,code_postal,telephone,code_categorie)
VALUES($n_client,$raison_sociale,$adresse,$ville,$code_postal,$telephone,$code_categorie)";
mysql_query($reponse2) or die("ERR : " . mysql_error() . "<br />SQL = ". $reponse2);
echo"Votre ajout a été effectué." ;
}
mysql_close();
?> |
Partager