Advertisement
Guest User

Untitled

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