Code : Tout sélectionner
<?php
if(isset($_POST['submit']))
{
$sexe = mysql_real_escape_string(htmlspecialchars(trim($_POST['sexe'])));
$pseudo = mysql_real_escape_string(htmlentities(trim($_POST['pseudo'])));
$password = mysql_real_escape_string(htmlentities(trim($_POST['password'])));
$repeatpassword = mysql_real_escape_string(htmlentities(trim($_POST['repeatpassword'])));
$email = mysql_real_escape_string(htmlentities(trim($_POST['email'])));
$apropos = mysql_real_escape_string(htmlentities(trim($_POST['apropos'])));
$situation = mysql_real_escape_string(htmlspecialchars(trim($_POST['situation'])));
if(empty($pseudo))
{
$errors[] = "Veuillez saisir un pseudo";
}
if(empty($password))
{
$errors[] = "Veuillez saisir un password";
}
if($password != $repeatpassword)
{
$errors[] = "Vos deux password doivent etre identiques";
}
if (!preg_match("#^[a-z0-9._-]+@[a-z0-9._-]{2,}\.[a-z]{2,4}$#", $_POST['email']))
{
$errors[]="Votre adresse email n'est pas correcte";
}
if(empty($apropos))
{
$errors[]="Veuillez vous decrire en quelques lignes";
}
if(pseudo_existe($pseudo)==1)
{
$errors[]="Ce pseudo n'est pas disponible";
}
if(email_existe($email)==1)
{
$errors[]="Cette adresse email existe deja <br> avez vous oublie votre <a href='#'>password?</a>" ;
}
if(!empty($errors))
{
foreach($errors as $error)
{
echo "<div class='error'>".$error."</div>";
}
}else{
inscrire_utilisateur($pseudo,$password,$email,$sexe,$situation,$apropos);
die('Inscription terminee,Vous pouvez vous <a href=\'index.php?page=login\'>connecter</a>');
}
}
?>
<form method='POST' action=''>
<label for='sexe'>Sexe</label>
<select name="sexe">
<?php echo isset($sexe) ? '<option value='.$sexe.'>'.$sexe.'</option>' :'';?>
<?php echo $sexe!='Homme' ? '<option value="Homme">Homme</option>' :'';?>
<?php echo $sexe!='Femme' ? '<option value="Femme">Femme</option>' :'';?>
</select><br/><br/>
<label for='situation'>Situation</label>
<select name="situation">
<?php echo isset($situation) ? '<option value='.$situation.'>'.$situation.'</option>' :'';?>
<?php echo $situation!='Celibataire'?'<option value="Celibataire">Celibataire</option>':'';?>
<?php echo $situation!='En couple'?'<option value="En couple">En couple</option>':'';?>
<?php echo $situation!='Divorce(e)'?'<option value="Divorce(e)">Divorce(e)</option>':'';?>
<?php echo $situation!='Veuf(ve)'?'<option value="Veuf(ve)">Veuf(ve)</option>':'';?>
</select><br/><br/>