Advertisement
Guest User

Untitled

a guest
Sep 14th, 2017
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.32 KB | None | 0 0
  1. <? php
  2.  
  3.  
  4.  
  5. $submit = ($_POST['submit']);
  6.  
  7.  
  8. //form data
  9. $firstname = strip_tags($_POST['firstname']);
  10. $surname = strip_tags($_POST['surname']);
  11. $username = ($_POST['username']);
  12. $password = strip_tags($_POST['password']);
  13. $confirmpassword = strip_tags($_POST['confirmpassword']);
  14. $daate = date("y-m-d");
  15.  
  16. if ($submit)
  17. {
  18.  
  19.  
  20. //check for existance
  21.  
  22. if ($firstname&&$surname&&$username&&$password&&$confirmpassword);
  23.  
  24. {
  25.  
  26. if ($password==$confirmpassword);
  27. {
  28. //check char length of username and fullname
  29.  
  30. if (strlen($username)>25||strlen($firstname)>25)
  31. {
  32.  
  33. echo "Length of Username or First name is too long";
  34.  
  35.  
  36. }
  37. else
  38. {
  39. //check password length
  40. if (strlen($password)>25||strlen($password)<6)
  41. {
  42. echo "Password must be between 6 and 25 characters";
  43. }
  44. else
  45. {
  46. //register the user
  47.  
  48. //encrypt password
  49. $password = md5($password);
  50. $confirmpassword = md5($confirmpassword);
  51.  
  52. //open database
  53. $connect = mysql_connect("mysql11.000webhost.com","a4264749_login","billyjoe16");
  54. mysql_select_db("a4264749_login"); //select database
  55.  
  56. $queryreg = mysql_query("INSERT INTO users VALUES ('$name','$surname','$username','$password','$date')");
  57.  
  58. die ("You have been registered! <a href='login.html'>Click here</a>to login ");
  59.  
  60.  
  61.  
  62.  
  63. }
  64.  
  65. }
  66.  
  67.  
  68.  
  69.  
  70.  
  71. }
  72. {
  73. else
  74. echo "Your passwords do not match!";
  75. }
  76. {
  77.  
  78.  
  79.  
  80.  
  81.  
  82.  
  83.  
  84. }
  85. {
  86. else
  87. echo "Please fill in <b>all</b> fields!";
  88. }
  89.  
  90.  
  91. }
  92.  
  93. }
  94.  
  95.  
  96. ?>
  97.  
  98.  
  99.  
  100.  
  101.  
  102.  
  103.  
  104. <html>
  105. <head>
  106. <style type="text/css">
  107. a:link {color:blue;text-decoration:none;}
  108. a:visited {color:red;text-decoration:none;}
  109. a:hover {color:orange;text-decoration:underline;}
  110. </style>
  111. </head>
  112. <body>
  113.  
  114. <p>
  115. <form action='register.php' nethod='POST'>
  116.  
  117.  
  118. <table>
  119.  
  120. <td>
  121. <tr>
  122.  
  123. First Name
  124.  
  125. </tr>
  126. <tr>
  127. <input type='text' name='first name' value='<?php echo $firstname ?>'
  128. </td><br>
  129. <tr>
  130. Surname
  131. </tr>
  132. <tr>
  133. <input type='text' name='surname' value='<?php echo $surname ?>'
  134. </tr><br>
  135. <tr>
  136. Desired Username:
  137. </tr>
  138. <tr>
  139. <input type='text' name='username' value='<?php echo $username ?>'
  140. </tr><br>
  141. <tr>
  142. Choose a password:
  143. </tr>
  144. <tr>
  145. <input type='password' name='password'>
  146. </tr>
  147. <br>
  148. <tr>
  149. Confirm password:
  150. </tr>
  151. <tr>
  152. <input type='password' name='confirm password'>
  153. </tr>
  154. <br>
  155. <input type='submit' name='submit' value='Register'>
  156.  
  157. </td>
  158.  
  159. </table>
  160.  
  161.  
  162.  
  163. </form>
  164.  
  165.  
  166. </body>
  167. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement