Advertisement
Guest User

Untitled

a guest
Sep 21st, 2017
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.11 KB | None | 0 0
  1. <?php
  2.  
  3. /*
  4. LiquidBB
  5.  
  6. File Name: Register
  7. File Description: Registers the user.
  8. Author: Brad Veryard.
  9.  
  10. */
  11.  
  12. include ("./inc/class_db.php");
  13.  
  14. $page = isset($_POST['page']) ? $_POST['page'] : '';
  15. $error = '';
  16. if ($page == 'register') {
  17. $username = $_POST['username'];
  18. $password = ($_POST['password']);
  19. $email = $_POST['email'];
  20. $gender = $_POST['gender'];
  21.  
  22. if ($username == "") {
  23. echo("Please fill in the username feild.");
  24. }
  25.  
  26. elseif ($password == "") {
  27. echo("Please fill in the password feild.");
  28. }
  29.  
  30. elseif ($email == "") {
  31. echo("Please fill in the email feild.");
  32. }
  33.  
  34. // Check see if username & email is taken
  35. elseif ($error == ""){
  36. $result = mysql_query("SELECT id FROM users WHERE username='{$username}'");
  37. if (mysql_num_rows($result) > 0) {
  38. echo ("Looks like that username is already in use.<br />");
  39. }
  40. }
  41.  
  42. elseif ($error == "") {
  43. $result = mysql_query("SELECT id FROM users WHERE email='{$email}'");
  44. if (mysql_num_rows($result) > 0) {
  45. echo ("Looks like that email is already in use.");
  46. }
  47. }
  48.  
  49. else {
  50. $username = mysql_real_escape_string($username);
  51. $password = sha1($password);
  52. $email = mysql_real_escape_string($email);
  53. mysql_query("INSERT INTO users (username, password, email, gender) VALUES ('{$username}','{$password}','{$email}','{$gender}')");
  54. echo("
  55. <html>
  56. <head>
  57. <title>Registered - ".$username."</title>
  58. <!--
  59. function delayer(){
  60. window.location = \"./index.php\"
  61. }
  62. //-->
  63. </head>
  64. <body onLoad=\"setTimeout('delayer()', 700)\">
  65. Thanks for registering!
  66. </body>
  67. </html>");
  68. }
  69. }
  70. ?>
  71.  
  72. <html>
  73. <head>
  74. <title>Register</title>
  75. </head>
  76.  
  77. <body>
  78. <h1>Register</h1>
  79. <form action="./user.php?do=register" method="POST">
  80. <input type="hidden" name="page" value="register">
  81. Username: <br /><input type="text" name="username"><br />
  82. Password: <br /><input type="password" name="password"><br />
  83. Email: <br /><input type="email" name="email"><br />
  84. Gender: <br /><select name="gender">
  85. <option> ------ </option>
  86. <option>Male</option>
  87. <option>Female</option>
  88. </select><br />
  89. <input type="submit" name="submit" value="Register">
  90. </form>
  91. <body>
  92. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement