Advertisement
Guest User

Untitled

a guest
Jun 19th, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.73 KB | None | 0 0
  1. <?php
  2. require './conn/connect.php';
  3.  
  4. //connect to MySQL or return an error
  5. $conn = @mysql_connect($dbhost, $dbuser, $dbpass)
  6. or die('Could not connect , Try it later ...');
  7.  
  8. //set database name
  9. $dbname = "l2jdb";
  10.  
  11. //select database or return an error
  12. $dbselect = mysql_select_db("$dbname")
  13. or die ('Could not select database , Try it later ...');
  14.  
  15. //get username and password info from the form, protecting against SQL injection
  16. $pass = mysql_real_escape_string($_POST["pass"]);
  17. $confirm = mysql_real_escape_string($_POST["confirm"]);
  18. $user = mysql_real_escape_string($_POST["name"]);
  19. $email = mysql_real_escape_string($_POST["mail"]);
  20.  
  21. if($_POST['submit'])
  22. {
  23. if( trim($pass) != "" && trim($confirm) != "" && trim($user) != "" && trim($email) != "" )
  24. {
  25. //validate user input
  26. if(!preg_match('/^[a-zA-Z0-9]{5,14}$/',$user))
  27. {
  28. header("Location: account-1.html");
  29. die();
  30. //die ('Usernames can only contain alphanumeric characters and must be between 5 and 20 characters in length.');
  31. }
  32. else if(!preg_match('/^[a-zA-Z0-9]{5,20}$/',$pass))
  33. {
  34. header("Location: account-1.html");
  35. die();
  36. //die('Passwords can only contain alphanumeric characters and must be between 5 and 20 characters in length.');
  37. }
  38. else if(!preg_match('/^[a-zA-Z0-9]{5,30}$/',$email))
  39. {
  40. header("Location: account-1.html");
  41. die();
  42. //die('Passwords can only contain alphanumeric characters and must be between 5 and 20 characters in length.');
  43. }
  44. else if($pass != $confirm)
  45. {
  46. header("Location: account-1.html");
  47. die();
  48. }
  49. else
  50. {
  51. //make sure user doesn't already exist and if it doesn't, add new record to the database
  52. $result = mysql_query("SELECT login FROM accounts WHERE login='$user'");
  53. $mailresult = mysql_query("SELECT email FROM account_email WHERE email='$email'");
  54.  
  55. if(mysql_num_rows($result)>0 || mysql_num_rows($mailresult)>0)
  56. {
  57. echo "Email or account allready in use . choose a other account or email .";
  58. die();
  59. //die ('Username already exists.');
  60. }
  61. else
  62. {
  63. mysql_query("INSERT INTO accounts (login, password, accessLevel) VALUES ('".$_POST['name']."', '".base64_encode(pack('H*', sha1($_POST['pass'])))."', 0)");
  64. mysql_query("INSERT INTO account_email (login, email) VALUES ('".$_POST['name']."', '".$_POST['mail']."')")
  65. or die ('Error: ' . mysql_error());
  66. }
  67.  
  68. //report successful registration
  69. //header("Location: account-5.html");
  70. echo "Account created successfully.";
  71.  
  72. //close MySQL connection
  73. mysql_close();
  74. }
  75. }
  76. else
  77. {
  78. header ("Location : Error1.html");
  79. return;
  80. }
  81. }
  82. else
  83. {
  84. echo "Account Manager for Lineage 2 Avocado<br>Leave This Page :)";
  85. //close MySQL connection
  86. mysql_close();
  87. }
  88. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement