31 lines
1.3 KiB
PHP
31 lines
1.3 KiB
PHP
<?php session_start();
|
|
include_once 'includes/bdd.php';
|
|
if(isset($_POST['pseudo']) && isset($_POST['mdp']) && isset($_POST['mdp2'])){
|
|
if($_POST['mdp'] === $_POST['mdp2']){
|
|
if(preg_match("#^[a-zA-Z0-9\\-_]+$#",$_POST['pseudo'])){
|
|
if(preg_match("#^[abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789\\-_&éèàùçµ\"\\#'{}()[\\]|\\^@°+=\$¤£*!§:/;.,?²]+$#",$_POST['mdp'])){
|
|
$req = $bdd->prepare("SELECT * FROM users WHERE pseudo=?");
|
|
$req->execute(array($_POST['pseudo']));
|
|
if($req->fetch()){
|
|
header('Location:register.php?i=5');
|
|
}else{
|
|
$req = $bdd->prepare('INSERT INTO users(pseudo,mdp,date_creation) VALUES (?,?,NOW())');
|
|
$req->execute(array($_POST['pseudo'],$_POST['mdp']));
|
|
$_SESSION['session_id'] = $reponce['ID'];
|
|
$_SESSION['session_mdp'] = $reponce['mdp'];
|
|
header('Location:register.php?i=6');
|
|
}
|
|
}else{
|
|
header('Location:register.php?i=4');
|
|
}
|
|
}else{
|
|
header('Location:register.php?i=3');
|
|
}
|
|
}else{
|
|
header('Location:register.php?i=2');
|
|
}
|
|
}else{
|
|
header('Location:register.php?i=1');
|
|
}
|
|
|
|
?>
|