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
| <?php
//ON se connecte à la base de donneés
try
{
$bdd = new PDO('mysql:host=localhost;dbname=andrea;charset=utf8', 'root', 'root');
}
catch(Exception $e)
{
die('Erreur : '.$e->getMessage());
}
if(isset($_POST['form_inscription']))
{
$pseudo = htmlspecialchars($_POST['pseudo']);
$email = htmlspecialchars($_POST['email']);
$email2 = htmlspecialchars($_POST['email2']);
$mdp = htmlspecialchars($_POST['mdp']);
$mdp2 = htmlspecialchars($_POST['mdp2']);
if(!empty($_POST['pseudo']) AND !empty($_POST['mdp']) AND !empty($_POST['mdp2']) AND !empty($_POST['email']) AND !empty($_POST['email2']))
{
if(isset($_POST['pseudo'],$_POST['mdp'],$_POST['mdp2'],$_POST['email'],$_POST['email2']))
{
//On controle si il n'y a pas deja d'autres membres avec le même pseudo
$requete = $bdd->prepare('SELECT pseudo FROM membres where pseudo = ?');
$requete->execute(array($pseudo));
if ($requete->fetch() == false)
{
if(($mdp == $mdp2) AND ($email == $email2) AND preg_match("#^[a-z0-9._-]+@[a-z0-9._-]{2,}\.[a-z]{2,4}$#", $email))
{
$req = $bdd->prepare("INSERT INTO membres(pseudo, mdp, email, date_inscription) VALUES(?, ?, ?, CURDATE())");
$req->execute(array($pseudo, $hmdp= password_hash($mdp, PASSWORD_DEFAULT), $email));
?><p><?php $inscrit= 'Vous etes inscrits!';?></p> |
Partager