le 09/01/2010 à 21:34
abonnement avec espace membre
ce scripte reste statique malgré tous les changement que j'ai pu effectué
voici le code
voici le code
<?php
include ("fonctions.php");
//itialistation des variable pour lavalidation d'adresse mail
$regex = "/^[-+.\w]{1,64}@[-.\w]{1,64}\.[-.\w]{2,6}$/i";
$mail= $_POST['mail'];
// ton teste si le formulaire est soumis
if (isset($_POST['valider']) and $_POST['valider']=='OK'){
/* on verifie l'existence des variables et si tous les champs
du formulaire on ete correctement remplis*/
if ((isset($_POST['login'])&& !empty($_POST['login'])) and
(isset($_POST['pass'])&& !empty($_POST['pass']))and
(isset($_POST['pass_confirm'])&& !empty($_POST['pass_confirm']))and
(isset($_POST['mail']) && !empty($_POST['mail']))and
(isset($_POST['civilite']) && !empty($_POST['civilite']))and
(isset($_POST['nom']) && !empty($_POST['nom']))and
(isset($_POST['prenom']) && !empty($_POST['prenom']))and
(isset($_POST['age']) && !empty($_POST['age']))and
(isset($_POST['ville']) && !empty($_POST['ville']))and
(isset($_POST['activite']) && !empty($_POST['activite']))and
(isset($_POST['adresse']) && !empty($_POST['adresse']))and
(isset($_POST['cp']) && !empty($_POST['cp']))and
(isset($_POST['tel']) && !empty($_POST['tel']))and
(isset($_POST['abo'])&& !empty($_POST['abo']))){
// vérification si les deux mots de passe sont identiques
if($_POST['pass'] != $_POST['pass_confirm']){
$erreur= 'Les deux mots de passe sont différents';
}
else{
// si tout est OK on se connecte à la BD Test
connectTest();
// on recherche si ce login est deja utilise
$sql='SELECT count(*) FROM Abonnes WHERE Login="
'.mysql_escaoe_string($_POST['login']).'" AND
Mail="'.mysql_escape_string($_POST['mail']).'"';
$req= mysql_query($sql) or die ('Erreur SQL! '.$sql.'<br/>'.mysql_error());
$data = mysql_fetch_array($req);
mysql_free_result($req);
mysql_close();
if ($data[0] == 0){
$sql = 'INSERT INTO Abonnes VALUES("", "'.mysql_escape_string($_POST['login']).'",
"'.mysql_escape_string(md5($_POST['pass'])).'", "'.mysql_escape_string($_POST['mail']).'",
"'.mysql_escape_string($_POST['civilite']).'","'.mysql_escape_string($_POST['nom']).'",
"'.mysql_escape_string($_POST['prenom']).'", "'.mysql_escape_string($_POST['age']).'",
"'.mysql_escape_string($_POST['pays']).'", "'.mysql_escape_string($_POST['ville']).'",
"'.mysql_escape_string($_POST['adresse']).'", "'.mysql_escape_string($_POST['cp']).'",
"'.mysql_escape_string($_POST['tel']).'")';
mysql_query($sql) or die ('Erreur SQL! '.$sql.'<br/>'.mysql_error());
session_start();
$_SESSION['login'] = $_POST['login'];
header ('Location: abonnes.php');
exit();
}
else{
$erreur = 'Le login ou l\'email que vous avez entre sont indisponible';
}
}
}
else {
$errur = 'Au moins un des champs est vide, veuillez remplir tous les champs';
}
}
?>
<html>
<head><title>Abonnment au magazine</title>
</head>
<body>
<a href="abo.php">Abonnment</a>
<form method="POST" id="test"action="<?php echo basename(__FILE__);?>" enctype="multipart/form-data">
<table border="2px">
<tr>
<td><caption>Veuillez remplir tous les champs</caption></td></tr>
<tr>
<td><label for="login">Choisissez un login:</td>
<td><input type="text" name="login" id="login"
value="<?php if (isset($_POST['login'])) echo stripslashes(htmlentities(trim($_POST['login'])));?>"></td>
</tr>
<tr>
<td><label for="pwd">Mot de passe</td>
<td><input type="password" name="pass" id="pwd"
value="<?php if (isset($_POST['pass'])) echo stripslashes(htmlentities(trim($_POST['pass'])));?>"></td>
</tr>
<tr>
<td><label for="psd">Confirmer mot de passe</td>
<td><input type="password" name="pass" id="psd"
value="<?php if (isset($_POST['pass_confirm'])) echo stripslashes(htmlentities(trim($_POST['pass_confirm'])));?>"></td>
</tr>
<tr>
<td><label for="mail">E-mail:</td>
<td><input type="text" name="mail" id="mail"
value="<?php if (isset($_POST['mail'])) echo stripslashes(htmlentities(trim($_POST['mail'])));?>"></td>
</tr>
<tr>
<td rowspan="4"><label for="civ">Civilité:</td>
<tr><td><input type="radio" name="Civilite" checked="check" id="civ" value="monsieur"/> Monsieur</td></tr>
<tr><td><input type="radio" name="Civilite" id="civ" value="mademoiselle"/> Madémoiselle</td></tr>
<tr><td><input type="radio" name="Civilite" id="civ" value="madame"/> Madame</td></tr>
</tr>
<tr>
<td><label for="nom">Nom:</td>
<td><input type="text" name="nom" id="nom"
value="<?php if (isset($_POST['nom'])) echo stripslashes(htmlentities(trim($_POST['nom'])));?>"></td>
</tr>
<tr>
<td><label for="prenom">Prénom:</td>
<td><input type="text" name="prenom" id="prenom"
value="<?php if (isset($_POST['prenom'])) echo stripslashes(htmlentities(trim($_POST['prenom'])));?>"></td>
</tr>
<tr>
<td><label for="age">Age:</td>
<td><input type="text" name="age" id="age"
value="<?php if (isset($_POST['age'])) echo stripslashes(htmlentities(trim($_POST['age'])));?>"></td>
</tr>
<tr>
<td><label for="pays">E-mail:</td>
<td><input type="text" name="pays" id="pays"
value="<?php if (isset($_POST['pays'])) echo stripslashes(htmlentities(trim($_POST['pays'])));?>"></td>
</tr>
<tr>
<td><label for="ville">Ville:</td>
<td><input type="text" name="ville" id="ville"
value="<?php if (isset($_POST['ville'])) echo stripslashes(htmlentities(trim($_POST['ville'])));?>"></td>
</tr>
<tr>
<td><label for="act">Activité:</td>
<td><input type="text" name="activite" id="act"
value="<?php if (isset($_POST['activite'])) echo stripslashes(htmlentities(trim($_POST['activite'])));?>"></td>
</tr>
<tr>
<td><label for="add">Adresse:</td>
<td><input type="text" name="adresse" id="add"
value="<?php if (isset($_POST['adresse'])) echo stripslashes(htmlentities(trim($_POST['adresse'])));?>"></td>
</tr>
<tr>
<td><label for="cp">Code Postal:</td>
<td><input type="text" name="CP" id="cp"
value="<?php if (isset($_POST['cp'])) echo stripslashes(htmlentities(trim($_POST['cp'])));?>"></td>
</tr>
<tr>
<td><label for="tel">Téléphone:</td>
<td><input type="text" name="tel" id="tel"
value="<?php if (isset($_POST['tel'])) echo stripslashes(htmlentities(trim($_POST['tel'])));?>"></td>
</tr>
</table>
<table border="8px">
<tr>
<td><caption>Veuillez Choisir un magazine</caption></td></tr>
<tr>
<td rowspan="5"><label for="abo">Magazine:</td>
<tr><td><input type="radio" name="Abo" id="abo" value="oeil" /> J'ai l'oeil vif</td></tr>
<tr><td><input type="radio" name="Abo" id="civ" value="pied">J'ai le pied marin</td></tr>
<tr><td><input type="radio" name="Abo" id="civ" value="rate"> J'ai la rate qui se dilate</td></tr>
<tr><td><input type="radio" name="Abo" id="abo" value="abo"> J'ai la maint verte</td></tr>
</td>
</tr>
<tr align="center">
<td border="none" ></td>
<td><input type="submit" name="valider" value="OK"><input type="reset" name="annuler" value="Effacer"></td>
</tr>
</table>
</form>
<?php
if (isset($erreur)) echo '<br/>',$erreur;
?>
</body>
</html>