À l'aide,
je suis en train de suivre un livre pour apprendre php et il me donne le code suivant:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"
"http://www.w3.org/TR/REC-html40/strct.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Ajout de compagnie</title>
<style type="text/css">
table {border-style:double;border-width:3px,border-color:red;background-color:yellow;}
</style>
</head>
<body>
<form action= "<?php echo $_SERVER['PHP_SELF'];?>" method="post"
enctype="application/x-www/form/urlenconded">
<fieldset>
<legendre><b>Information compagnie</b></legendre>
<table>
<tr>
<td>Nom:</td>
<td><input type="text" name="nom_compagniecompagnie" size="100" maxlength="100"/></td>
</tr>
<tr>
<td>Contact:</td>
<td><input type="text" name="nom_contact" size="100" maxlength="100"/></td>
</tr>
<tr>
<td>Addresse:</td>
<td><input type="text" name="addresse" size="100" maxlength="100"/></td>
</tr>
<tr>
<td>Ville:</td>
<td><input type="text" name="ville" size="100" maxlength="100"/></td>
</tr>
<tr>
<td>Code postal</td>
<td><input type="text" name="code_postal" size="100" maxlength="6"/></td>
</tr>
<tr>
<td>Téléphone:</td>
<td><input type="text" name="telephone" size="100" maxlength="10"/></td>
</tr>
<tr>
<td>Fax:</td>
<td><input type="text" name="fax" size="100" maxlength="10"/></td>
</tr>
<tr>
<td>Province:</td>
<td><input type="text" name="province" size="100" maxlength="10"/</td>
</tr>
<Tr>
<td><input type="reset" value=" Effacer "/></td>
<td><input type="submit" value=" Envoyer "/></td>
</tr>
</table>
</fieldset>
</form>
<?php
include('connex.inc.php');
if(!empty($_POST['nom_compagnie'])&& !empty($_POST['nom_contact'])&& !empty($_POST['addresse'])&& !empty($_POST['ville'])&& !empty($_POST['code_postal'])&& !empty($_POST['telephone'])&& !empty($_POST['province']))
{
$id_compagnie="\N";
$nom_compagnie=mysql_escape_string($_POST['nom_compangie']);
$nom_contact =mysql_escape_string($_POST['nom_contact']);
$addresse =mysql_escape_string($_POST['addresse']);
$ville = mysql_escape_string($_POST['ville']);
$code_postal =mysql_escape_string($_POST['code_postal']);
$telephone =mysql_escape_string($_POST['telephone']);
$fax =mysql_escape_string($_POST['fax']);
$province =mysql_escape_string($_POST['province']);
//requeste sql
$sql="INSERT INTO compagnie VALUES($id_compagnie','$nom_compagnie','$nom_contact','$addresse','$ville','$code_postal','$telephone','$fax','$province')";
$idcom=connex('gestion_mail','myparam');
$result=mysql_query($sql,$idcom);
mysql_close($idcom);
if(!$result)
{
echo mysql_errno();
echo mysql_error();
echo "<script type=\"text/javascript\">
alert('Erreur : ".mysql_error()."')</script>";
}
else
{
echo "<script type=\"text/javascript\">
alert('Vous êtes enregistré Votre numéro de client est : ". mysql_insert_id()."')</script>";
}
}
else
{
echo "<script type=\"text/javascript\">
alert('passer tous droit')</script>";
}
?>
</body>
</html>
me ja passe directement a mon alert('passer tous droit'). Est-ce qu'il a quelqu'un qui pourrais me dire ce qui va pas avec ca. parce que je veux bien apprendre mais si ca marche pas d'avance......
pour le include("connex.inc.php") et connex("db","myparam") c'Est fichier marche avec d'autre script que j'ai fais.
merci d'avance
mataxa