HoogleyBoogley

My Code

Aug 6th, 2016
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 5 3.78 KB | None | 0 0
  1. <?php include ( "inc/header.php" ) ?>
  2. <?
  3. $reg = @$_POST['reg'];
  4. //declaring variables to prevent errors
  5. $fn = ""; //First Name
  6. $ln = ""; //Last Name
  7. $un = ""; //Username
  8. $em = ""; //Email
  9. $em2 = ""; //Email 2
  10. $pswd = ""; //Password
  11. $pswd2 = ""; // Password 2
  12. $d = ""; // Sign up Date
  13. $u_check = ""; // Check if username exists
  14. //registration form
  15. $fn = strip_tags(@$_POST['fname']);
  16. $ln = strip_tags(@$_POST['lname']);
  17. $un = strip_tags(@$_POST['uname']);
  18. $em = strip_tags(@$_POST['email']);
  19. $em2 = strip_tags(@$_POST['email2']);
  20. $pswd = strip_tags(@$_POST['password']);
  21. $pswd2 = strip_tags(@$_POST['password2']);
  22. $d = date("Y-m-d"); // Year - Month - Day
  23.  
  24. if ($reg) {
  25. if ($em==$em2) {
  26. // Check if user already exists
  27. $u_check = mysqli_query("SELECT username FROM users WHERE username='$un'");
  28. // Count the amount of rows where username = $un
  29. $check = mysqli_num_rows($u_check);
  30. //Check whether Email already exists in the database
  31. $e_check = mysqli_query("SELECT email FROM users WHERE email='$em'");
  32. //Count the number of rows returned
  33. $email_check = mysqli_num_rows($e_check);
  34. if ($check == 0) {
  35.  if ($email_check == 0) {
  36. //check all of the fields have been filed in
  37. if ($fn&&$ln&&$un&&$em&&$em2&&$pswd&&$pswd2) {
  38. // check that passwords match
  39. if ($pswd==$pswd2) {
  40. // check the maximum length of username/first name/last name does not exceed 25 characters
  41. if (strlen($un)>25||strlen($fn)>25||strlen($ln)>25) {
  42. echo "The maximum limit for username/first name/last name is 25 characters!";
  43. }
  44. else
  45. {
  46. // check the maximum length of password does not exceed 25 characters and is not less than 5 characters
  47. if (strlen($pswd)>30||strlen($pswd)<5) {
  48. echo "Your password must be between 5 and 30 characters long!";
  49. }
  50. else
  51. {
  52. //encrypt password and password 2 using md5 before sending to database
  53. $pswd = md5($pswd);
  54. $pswd2 = md5($pswd2);
  55. $query = mysqli_query("INSERT INTO users VALUES ('','$un','$fn','$ln','$em','$pswd','$d','0','Write something about yourself.','','','no')");
  56. die("<h2>Welcome to the HoogleyBoogley Network</h2>Login to your account to get started ...");
  57. }
  58. }
  59. }
  60. else {
  61. echo "Your passwords don't match!";
  62. }
  63. }
  64. else
  65. {
  66. echo "Please fill in all of the fields";
  67. }
  68. }
  69. else
  70. {
  71.  echo "Sorry, but it looks like someone has already used that email!";
  72. }
  73. }
  74. else
  75. {
  76. echo "Username already taken ...";
  77. }
  78. }
  79. else {
  80. echo "Your E-mails don't match!";
  81. }
  82. }
  83. ?>
  84.     <div class="container">
  85.         <div id="home_login">
  86.             <table>
  87.                 <tr>
  88.                     <td width="60%" valign="top">
  89.                         <h2>Join Us Today!</h2>
  90.                     </td>
  91.                     <td width="40%" valign="top">
  92.                         <h2>Sign Up Now!</h2>
  93.                         <form action="#" method="post">
  94.                             <input type="text" name="fname" size="25" placeholder="First Name"><br /><br />
  95.                             <input type="text" name="lname" size="25" placeholder="Last Name"><br /><br />
  96.                             <input type="text" name="uname" size="25" placeholder="Username"><br /><br />
  97.                             <input type="text" name="email" size="25" placeholder="Email Address"><br /><br />
  98.                             <input type="text" name="email2" size="25" placeholder="Comfirm Email Address"><br /><br />
  99.                             <input type="text" name="password" size="25" placeholder="Password"><br /><br />
  100.                             <input type="text" name="password2" size="25" placeholder="Comfirm Password"><br /><br />
  101.                             <input type="submit" name="reg" value="Sign Up" id="home_signup">
  102.                         </form>
  103.                     </td>
  104.                 </tr>
  105.             </table>
  106.         </div>
  107.     </div>
  108. <?php include ( "inc/footer.php" ) ?>
Advertisement
Add Comment
Please, Sign In to add comment