Guest User

Untitled

a guest
Jan 23rd, 2018
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.44 KB | None | 0 0
  1. <?php
  2. echo "<h1>Register</h1>";
  3.  
  4. $submit = $_POST[submit];
  5.  
  6. //form data
  7. $fullname = strip_tags($_POST['fullname']);
  8. $username = srtolower(strip_tags($_POST['username']));
  9. $password = strip_tags($_POST['password']);
  10. $repeatpassword = strip_tags($_POST['repeatpassword']);
  11. $date = date("Y-m-d");
  12.  
  13. if ($submit)
  14. {
  15.  
  16. //open database
  17. $connect = mysql_connect("localhost","root","");
  18. mysql_select_db("itzlghts_files"); //select database
  19.  
  20. $namecheck = mysql_query("SELECT username FROM users WHERE username='$username'");
  21. $count = mysql_num_rows($namecheck);
  22.  
  23. if($count!=0))
  24. {
  25. die("Username is already in use!");
  26. }
  27.  
  28. //check for excistance
  29. if ($fullname&&$username&&$password&&$repeatpassword)
  30. {
  31.  
  32. if ($password==$repeatpassword)
  33. {
  34.  
  35. //check char lenth of username and full name
  36. if (strlen($username)>25||strlen($fullname)>25)
  37. {
  38. echo "Length of username or full name is too long!"
  39. }
  40. else
  41. {
  42.  
  43. //check password lenth
  44. if (strlen$password)>25||strlen($password)<6)
  45. {
  46. echo "Password must be between 6 and 25 characters."
  47. }
  48. else
  49. {
  50. //register the user!
  51.  
  52. //encrypt password
  53. $password = md5($password);
  54. $repeatpassword = md5($repeatpassword);
  55.  
  56.  
  57.  
  58. $queryreg = mysql_query("
  59.  
  60. INSERT INTO users VALUES (''', '$fullname', '$username', '$password', '$date')
  61.  
  62. ");
  63.  
  64. die("You have been registered! ,<a href='index.php'>Return to login page</a>");
  65.  
  66.  
  67. }
  68.  
  69. }
  70.  
  71.  
  72. }
  73. else
  74. echo "Your passwords do not match!";
  75.  
  76.  
  77.  
  78. }
  79. else
  80. else "Please fill in <b>all</b> fields!";
  81.  
  82.  
  83. }
  84.  
  85. ?>
  86.  
  87. <html>
  88. <p>
  89. <form action='register.php' method='POST'>
  90. <table>
  91. <tr>
  92. <td>
  93. Your full name:
  94. </tb>
  95. <td>
  96. <input type='text' name='fullname' value='<?php echo $fullname; ?>'>
  97. </td>
  98. </tr>
  99. <tr>
  100. <td>
  101. Choose a username:
  102. </tb>
  103. <td>
  104. <input type='text' name='username' value='<?php echo $username; ?>'>
  105. </td>
  106. </tr>
  107. <tr>
  108. <td>
  109. Choose a password:
  110. </tb>
  111. <td>
  112. <input type='password' name='password'>
  113. </td>
  114. </tr>
  115. <tr>
  116. <td>
  117. Repeat your password:
  118. </tb>
  119. <td>
  120. <input type='password' name='repeat password'>
  121. </td>
  122. </tr>
  123. </table>
  124. <p>
  125. <input type='submit' name='submit' value='Register'>
  126. </form>
  127.  
  128. </html>
Add Comment
Please, Sign In to add comment