Back';
include_once('bottom.php');
return FALSE;
}
if($passwd!=$passwd2)
{
echo'Passwords don\'t match !
Back';
include_once('bottom.php');
return FALSE;
}
if(!$username || strlen($username) > 15)
{
echo'Your username is inexisant or is more than 15 caracters...
Back';
include_once('bottom.php');
return FALSE;
}
if(!$email)
{
echo'Your e-mail is innexistant.
Back';
include_once('bottom.php');
return FALSE;
}
//// VERIFICATIONS DES EXISTANCES ////
$reponse_mail=$dbh->query("SELECT email FROM user WHERE email='$email'") or die ('error : '.mysql_error()); //verification si e-mail existe déjà
$count_mail=$reponse_mail->rowCount();
if($count_mail == 1)
{
echo'This e-mail is already taken.
Back';
include_once('bottom.php');
return FALSE;
}
$reponse_username=$dbh->query("SELECT username FROM user WHERE username='$username'") or die ('error : '.mysql_error()); //verification si username existe déjà
$count_username=$reponse_username->rowCount();
if($count_username == 1)
{
echo 'This username is already taken.
Back';
include_once('bottom.php');
return FALSE;
}
for ($ligne=0;$ligne<30;$ligne++)
{
@$session.=substr('0123456789AZERTYUIOPMLKJHGFDSQWXCVBN',(rand()%(strlen('0123456789AZERTYUIOPMLKJHGFDSQWXCVBN'))),1);
}
$passwd=md5($passwd); //Codage du password
//// DEFINIR LE PREMIER UTILISATEUR COMME ADMINISTRATEUR ////
$nombre_utilisateur=$dbh->query("SELECT * FROM user") or die ('error : '.mysql_error());
$count_user=$nombre_utilisateur->rowCount();
if($count_user == 0){
$user_rank = '1';
}else{
$user_rank ='0';
}
if(!isset($website_name))
{
$website_name = "Blog Artisanal";
}
//// INSCRIPTION DANS LA BDD ////
$sql_register = "INSERT INTO user ( id_user, session, username, pass, email, date, user_rank)
VALUES (:id_user, :session, :username, :pass, :email, :date, :user_rank)";
$query = $dbh->prepare($sql_register) or die ('error : '.mysql_error()); //insertion dans la bdd
$results = $query->execute(array(
"id_user" => '',
"session" => $session,
"username" => $username,
"pass" => $passwd,
"email" => $email,
"date" => '',
"user_rank" => $user_rank
));
echo'Thank you for registering to '.$website_name.'
Login !';
include_once('bottom.php');
?>