Guest User

Untitled

a guest
Jan 12th, 2018
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.41 KB | None | 0 0
  1. <?php include("../templates/connect.php");
  2.  
  3.  
  4. $username = mysql_real_escape_string($_POST['username']);
  5.  
  6. $password1= mysql_real_escape_string($_POST['password1']);
  7.  
  8. $password2= mysql_real_escape_string($_POST['password2']);
  9.  
  10. $email=mysql_real_escape_String($_POST['email']);
  11.  
  12. $user_ip=$_SERVER['REMOTE_ADDR'];
  13.  
  14.  
  15.  
  16. //---- need to make it so textboxes only allow letters and numbers for username, and password
  17.  
  18.  
  19. //---- this checks the variables against the database
  20. $sql = "SELECT * FROM usersxyz WHERE USERNAME='$username'";
  21. $check=mysql_query($sql);
  22. $res=mysql_num_rows($check);
  23.  
  24. $check2=mysql_query("SELECT * FROM usersxyz WHERE EMAIL='$email'");
  25. $res2=mysql_num_rows($check2);
  26.  
  27. $check3=mysql_query("SELECT * FROM usersxyz WHERE IPADDY='$user_ip'");
  28. $res3=mysql_num_rows($check3);
  29.  
  30. if($res > 0)
  31. {
  32. header("Location: /homepage/registration.php?username=used");
  33. }
  34. else if($res2 > 0)
  35. {
  36. header("Location: /homepage/registration.php?email=used");
  37. }
  38. else if(!preg_match('/.{2,20}@{1}.{2,20}\.{1}.{2,10}/', $email))
  39. {
  40. header("Location: /homepage/registration.php?email=invalid");
  41. }
  42. else if($password1!=$password2)
  43. {
  44. header("Location: /homepage/registration.php?password=unmatch");
  45. }
  46. else if(empty($username))
  47. {
  48. header("Location: /homepage/registration.php?username=empty");
  49. }
  50. else if(empty($password1))
  51. {
  52. header("Location: /homepage/registration.php?password=empty");
  53. }
  54. else if(empty($email))
  55. {
  56. header("Location: /homepage/registration.php?email=empty");
  57. }
  58. ELSE
  59. {
  60. $puppy=mysql_query("INSERT INTO usersxyz (USERNAME, PASSWORD, EMAIL, IPADDY) VALUES('$username', '$password1', '$email', '$user_ip')") or die(mysql_error());
  61. mysql_query("INSERT INTO logs (TYPE, CONTENT) VALUES ('2', 'User $username has registered.')") or die(mysql_error());
  62. if($res3 > 0) { mysql_query("INSERT INTO adminwarnings (SUBJECT, CONTENT) VALUES ('Possible Multi', 'A user with the IP $user_ip has recently registered. This IP has been used in multiple registrations, and could possibly be a multi. Please review logs, and invistigate possible misconduct')");}
  63. if (preg_match('~[^a-z0-9]~i',$username)) { mysql_query("INSERT INTO adminwarnings (SUBJECT, CONTENT) VALUES ('Possible Hack attempt', 'A user with IP $user_ip has registtered with the username: $username . This could possibly be an SQL Injection attempt. Please investigate.')"); }
  64. header("location: ../index.php?reg=1");
  65. }
  66.  
  67.  
  68. ?>
Add Comment
Please, Sign In to add comment