Guest User

Untitled

a guest
Jun 24th, 2018
353
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.05 KB | None | 0 0
  1. <?php
  2. include "includes/connect.php";
  3. $username = $_POST['username'];
  4. $email = $_POST['email'];
  5. $location = $_POST['location'];
  6. ?>
  7. <form action="<?php echo $_SERVER['PHP_SELF'] ?>" method="POST">
  8. Username:
  9. <input type="text" name="username" value="<?php echo $username; ?>" />
  10. <br>
  11. Email:
  12. <input type="text" name="email" value="<?php echo $email; ?>" />
  13. <br>
  14. Password:
  15. <input type="password" name="password1" />
  16. <br>
  17. Password(again):
  18. <input type="password" name="password2" />
  19. <br>
  20. Location:
  21. <input type="text" name="location" value="<?php echo $location; ?>" />
  22. <br />
  23. <?php
  24. $ip=$_SERVER['REMOTE_ADDR'];
  25. ?>
  26. Ip: <strong><?php echo "$ip" ?></strong><br />
  27. <br />
  28. <input name="terms" type="checkbox">
  29. I agree the Terms and Conditions <br />
  30. <br />
  31.  
  32. <input type="submit" name="submit" value="Register!" />
  33. </form>
  34. <?php
  35. $username = mysql_real_escape_string($_POST['username']);
  36. $email = mysql_real_escape_string($_POST['email']);
  37. $password1 = mysql_real_escape_string($_POST['password1']);
  38. $password2 = $_POST['password2'];
  39. $location = mysql_real_escape_string($_POST['location']);
  40. $terms = mysql_real_escape_string($_POST['terms']);
  41.  
  42. $userchecker = mysql_query("select * from users where username='$username'");
  43. $userchecker2 = mysql_num_rows($userchecker);
  44.  
  45. $namelength = strlen($username);
  46.  
  47. if(isset($_POST['username']))
  48. {
  49. if($password1 != $password2)
  50. {
  51. echo "Your passwords do not match!";
  52. }
  53. elseif($terms != on)
  54. {
  55. echo "You must agree before you can continue!";
  56. }
  57. elseif($namelength < 3)
  58. {
  59. echo "Your Username must be longer than 3 characters!";
  60. }
  61. elseif($userchecker2 > 0)
  62. {
  63. echo "Username is taken!";
  64. }
  65. else
  66. {
  67. $password = md5($password1);
  68. $result = mysql_query("INSERT INTO users (username, password, email, location) VALUES ('$username', '$password', '$email', '$location')");
  69.  
  70. if($result)
  71. {
  72. echo "Success!";
  73. ////////
  74. echo "<br />";
  75. echo $ip;
  76. ///////
  77. }
  78. else
  79. {
  80. echo "There was a Database error";
  81. }
  82. }
  83. }
  84.  
  85. ?>
Add Comment
Please, Sign In to add comment