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 49 50 51 52
| session_start();
if (isset($_POST['submit'])){
$ok=isset($_POST['nom']) && $_POST['nom'] != '' && $_POST['nom'] != NULL
&& isset($_POST['prenom']) && $_POST['prenom'] != '' && $_POST['prenom'] != NULL
&& isset($_POST['sexe']) && $_POST['sexe'] != '' && $_POST['sexe'] != NULL ;//etc. etc.
//ici bien sûr, il faut que tu termines la vérification exhaustive !
if($ok){
$nom=htmlentities(trim($_POST['nom']));
$prenom=htmlentities(trim($_POST['prenom']));
$sexe=htmlentities(trim($_POST['sexe']));
$date=htmlentities(trim($_POST['date']));
$num=htmlentities(trim($_POST['num']));
$code=htmlentities(trim($_POST['code']));
$username=htmlentities(trim($_POST['username'])); //virer espaces et tag
$password=htmlentities(trim($_POST['password']));
$repeatpassword=htmlentities(trim($_POST['repeatpassword']));
$type=htmlentities(trim($_POST['type']));
if($password==$repeatpassword){
//Crypter le password ;*/
$password=md5($password);
//Se connecter à la BDD
$connect=mysql_connect('localhost','root','') or die(Error);
mysql_select_db('bdd__messagerie'); //sélectionner BDD
//vérifier que pseudo pas déjà pris
$reg=mysql_query("SELECT * FROM personne WHERE login='$username'")or die(mysql_error());
$rows=mysql_num_rows($reg);
if ($rows==0){
if(mysql_query("INSERT INTO personne VALUES('','$nom','$prenom','$sexe','$date','$num','$code','$username','$password','','$type')")){
mysql_close();
//ça a marché, tu le connectes et tu le diriges vers l'accueil.
header('location:lasuite.php');
}
else{
$_SESSION['info']= "Il y a eu un problème à l'insertion !";
mysql_close();
}
}
else{
$_SESSION['info']= "Ce pseudo n'est pas disponible";
mysql_close();
}
}else $_SESSION['info']= "Les deux passwords doivent être identiques";
}else $_SESSION['info']="Veuillez saisir tous les champs";
}else $_SESSION['info']="Il faut passer par un formulaire";
header('location:login.php');
//et sur login.php, tu ajouteras
if(isset($_SESSION['info'])){
echo '<p style="color:red;">'.$_SESSION['info'].'</p>';
} |
Partager