123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- <?php
-
-
- require_once('config.php');
- $page_name='Register';
- include_once('top.php');
- $email=htmlspecialchars(formulaires($_POST['email']));
- $username=htmlspecialchars(formulaires($_POST['username']));
- $passwd=htmlspecialchars(formulaires($_POST['passwd']));
- $passwd2=htmlspecialchars(formulaires($_POST['passwd2']));
-
-
-
- //// VERIFICATIONS BANALES ////
- if(!$passwd || !$passwd2 || strlen($passwd) < 5)
- {
- echo'Your password or its confirmation is inexistant or your password is less than 5 characters<br /><a href="register.php" onClick="history.Back()">Back</a>';
- include_once('bottom.php');
- return FALSE;
- }
- if($passwd!=$passwd2)
- {
- echo'Passwords don\'t match !<br /><a href="register.php" onClick="history.Back()">Back</a>';
- include_once('bottom.php');
- return FALSE;
- }
- if(!$username || strlen($username) > 15)
- {
- echo'Your username is inexisant or is more than 15 caracters...<br /><a href="register.php" onClick="history.Back()">Back</a>';
- include_once('bottom.php');
- return FALSE;
- }
- if(!$email)
- {
- echo'Your e-mail is innexistant.<br /><a href="register.php" onClick="history.Back()">Back</a>';
- 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.<br /><a href="register.php" onClick="history.Back()">Back</a>';
- 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.<br /><a href="register.php" onClick="history.Back()">Back</a>';
- 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.'<br /><a href="index.php">Login !</a>';
- include_once('bottom.php');
- ?>
|