12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- <?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=$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.<br /><a href="register.php" onClick="history.Back()">Back</a>';
- 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.<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=$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.'<br /><a href="index.php">Login !</a>';
- include_once('bottom.php');
- ?>
|