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=mysql_query("SELECT email FROM user WHERE email='$email'") or die ('error : '.mysql_error()); //verification si e-mail existe déjà
$count_mail=mysql_num_rows($reponse_mail);
if($count_mail == 1)
{
echo'This e-mail is already taken.
Back';
include_once('bottom.php');
return FALSE;
}
$reponse_username=mysql_query("SELECT username FROM user WHERE username='$username'") or die ('error : '.mysql_error()); //verification si username existe déjà
$count_username=mysql_num_rows($reponse_username);
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=mysql_query("SELECT * FROM user") or die ('error : '.mysql_error());
$count_user=mysql_num_rows($nombre_utilisateur);
if($count_user == 0){
$user_rank = '1';
}else{
$user_rank ='0';
}
if(!isset($website_name))
{
$website_name = "Blog Artisanal";
}
//// INSCRIPTION DANS LA BDD ////
mysql_query("INSERT INTO user VALUES ('', '$session', '$username', '$passwd', '$email','','$user_rank')") or die ('error : '.mysql_error()); //insertion dans la bdd
echo'Thank you for registering to '.$website_name.'
Login !';
include_once('bottom.php');
?>