Guest User

Untitled

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