CMS ultra léger au style oldschool, projet de la communauté Kalaïn Hundin.

verification.php 3.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. <?php
  2. require_once('config.php');
  3. $page_name='Register';
  4. include_once('top.php');
  5. $email=htmlspecialchars(formulaires($_POST['email']));
  6. $username=htmlspecialchars(formulaires($_POST['username']));
  7. $passwd=htmlspecialchars(formulaires($_POST['passwd']));
  8. $passwd2=htmlspecialchars(formulaires($_POST['passwd2']));
  9. //// VERIFICATIONS BANALES ////
  10. if(!$passwd || !$passwd2 || strlen($passwd) < 5)
  11. {
  12. 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>';
  13. include_once('bottom.php');
  14. return FALSE;
  15. }
  16. if($passwd!=$passwd2)
  17. {
  18. echo'Passwords don\'t match !<br /><a href="register.php" onClick="history.Back()">Back</a>';
  19. include_once('bottom.php');
  20. return FALSE;
  21. }
  22. if(!$username || strlen($username) > 15)
  23. {
  24. echo'Your username is inexisant or is more than 15 caracters...<br /><a href="register.php" onClick="history.Back()">Back</a>';
  25. include_once('bottom.php');
  26. return FALSE;
  27. }
  28. if(!$email)
  29. {
  30. echo'Your e-mail is innexistant.<br /><a href="register.php" onClick="history.Back()">Back</a>';
  31. include_once('bottom.php');
  32. return FALSE;
  33. }
  34. //// VERIFICATIONS DES EXISTANCES ////
  35. $reponse_mail=$dbh->query("SELECT email FROM user WHERE email='$email'") or die ('error : '.mysql_error()); //verification si e-mail existe déjà
  36. $count_mail=$reponse_mail->rowCount();
  37. if($count_mail == 1)
  38. {
  39. echo'This e-mail is already taken.<br /><a href="register.php" onClick="history.Back()">Back</a>';
  40. include_once('bottom.php');
  41. return FALSE;
  42. }
  43. $reponse_username=$dbh->query("SELECT username FROM user WHERE username='$username'") or die ('error : '.mysql_error()); //verification si username existe déjà
  44. $count_username=$reponse_username->rowCount();
  45. if($count_username == 1)
  46. {
  47. echo 'This username is already taken.<br /><a href="register.php" onClick="history.Back()">Back</a>';
  48. include_once('bottom.php');
  49. return FALSE;
  50. }
  51. for ($ligne=0;$ligne<30;$ligne++)
  52. {
  53. @$session.=substr('0123456789AZERTYUIOPMLKJHGFDSQWXCVBN',(rand()%(strlen('0123456789AZERTYUIOPMLKJHGFDSQWXCVBN'))),1);
  54. }
  55. $passwd=md5($passwd); //Codage du password
  56. //// DEFINIR LE PREMIER UTILISATEUR COMME ADMINISTRATEUR ////
  57. $nombre_utilisateur=$dbh->query("SELECT * FROM user") or die ('error : '.mysql_error());
  58. $count_user=$nombre_utilisateur->rowCount();
  59. if($count_user == 0){
  60. $user_rank = '1';
  61. }else{
  62. $user_rank ='0';
  63. }
  64. if(!isset($website_name))
  65. {
  66. $website_name = "Blog Artisanal";
  67. }
  68. //// INSCRIPTION DANS LA BDD ////
  69. $sql_register = "INSERT INTO user ( id_user, session, username, pass, email, date, user_rank)
  70. VALUES (:id_user, :session, :username, :pass, :email, :date, :user_rank)";
  71. $query = $dbh->prepare($sql_register) or die ('error : '.mysql_error()); //insertion dans la bdd
  72. $results = $query->execute(array(
  73. "id_user" => '',
  74. "session" => $session,
  75. "username" => $username,
  76. "pass" => $passwd,
  77. "email" => $email,
  78. "date" => '',
  79. "user_rank" => $user_rank
  80. ));
  81. echo'Thank you for registering to '.$website_name.'<br /><a href="index.php">Login !</a>';
  82. include_once('bottom.php');
  83. ?>