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

verification.php 2.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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=mysql_query("SELECT email FROM user WHERE email='$email'") or die ('error : '.mysql_error()); //verification si e-mail existe déjà
  36. $count_mail=mysql_num_rows($reponse_mail);
  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=mysql_query("SELECT username FROM user WHERE username='$username'") or die ('error : '.mysql_error()); //verification si username existe déjà
  44. $count_username=mysql_num_rows($reponse_username);
  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=mysql_query("SELECT * FROM user") or die ('error : '.mysql_error());
  58. $count_user=mysql_num_rows($nombre_utilisateur);
  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. mysql_query("INSERT INTO user VALUES ('', '$session', '$username', '$passwd', '$email','','$user_rank')") or die ('error : '.mysql_error()); //insertion dans la bdd
  70. echo'Thank you for registering to '.$website_name.'<br /><a href="index.php">Login !</a>';
  71. include_once('bottom.php');
  72. ?>