Advertisement
Guest User

Untitled

a guest
Jun 9th, 2017
534
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.78 KB | None | 0 0
  1. <?php
  2.  
  3. ## Displaying form is no form has already been submitted
  4. if(!isset($_POST['submit'])) {
  5.  
  6. ## Creating a 'goto' point for later use
  7. form:
  8. ?>
  9. <html>
  10. <head />
  11. <!-- Sexy Style -->
  12. <STYLE>
  13. input{
  14. background-color: #2400ff; font-size: 8pt; color: white; font-family: Tahoma; border: 1 solid #66;
  15. }
  16. button{
  17. background-color: #2400ff; font-size: 8pt; color: white; font-family: Tahoma; border: 1 solid #66;
  18. }
  19. body {
  20. background-color: black;
  21. }
  22. </style>
  23. <!-- -->
  24. <form action='<?php echo $_SERVER['PHP_SELF']; ?>' method='post'>
  25. Username: <input type='text' name='username' /><br />
  26. Password: <input type='text' name='password' /><br />
  27. Password Confirmation: <input type='text' name='passwordc' /><br />
  28. Email: <input type='text' name='email' /><br />
  29. <input type='submit' name='submit' value='Sign Up' />
  30. </form>
  31. </html>
  32. <?php
  33. }
  34.  
  35. ## Processing if a form has been submitted
  36. else {
  37.  
  38. ## A little security measure
  39. $username = mysql_real_escape_string($_POST['username']);
  40. $username = htmlentities($username);
  41. $password = mysql_real_escape_string($_POST['password']);
  42. $passwordc = mysql_real_escape_string($_POST['passwordc']);
  43. $email = mysql_real_escape_string($_POST['email']);
  44.  
  45. ## Connecting to the database, you need to fill in with your information
  46. $con = mysql_connect('localhost', 'username', 'password');
  47. mysql_select_db('dbname', $con);
  48.  
  49. ## Checking to see if the username has been taken
  50. $check = sprintf("SELECT * FROM users WHERE Username='%s'", $username);
  51. $check_ = mysql_query($check);
  52. $check__count = mysql_num_rows($check_);
  53.  
  54. if($check__count > 0) { echo 'We already have a user signed up with that username. <br /><br />'; goto form; }
  55.  
  56. ## Checking to see if passwords match
  57. if($password != $passwordc) { echo 'Your two passwords do not match. <br /><br />'; goto form; }
  58.  
  59. ## Checking length of password
  60. if(strlen($password) < 4) { echo 'Your password is too short. Must be more than 4 characters. <br /><br />'; goto form; }
  61.  
  62. ## Checking to see if the email is taken
  63. $check = sprintf("SELECT * FROM users WHERE Email='%s'", $email);
  64. $check_ = mysql_query($check);
  65. $check__count = mysql_num_rows($check_);
  66.  
  67. if($check__count > 0) { echo 'We already have a user signed up with that email. <br /><br />'; goto form; }
  68.  
  69. ## Inserting information to the database, with the 'Type' set to 0, which means the account is not activated. You'll need to change it to 1 in order to activate the account
  70. $query = "INSERT INTO users (Username, Password, Email, Type) VALUES ('$username', '$password', '$email', '0')";
  71. mysql_query($query);
  72.  
  73. ## Sending a mail to you
  74. $to = 'youremail@yourdomain.com';
  75. $subject = 'User in need of activation';
  76. $message = 'A user has just registered with the username: ' . $username . '. He is need of activation.';
  77.  
  78. mail($to, $subject, $message);
  79. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement