Advertisement
Guest User

Untitled

a guest
May 11th, 2017
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.68 KB | None | 0 0
  1. <?
  2. echo "<h1>Register</h1>";
  3.  
  4. $submit = $_POST['submit'];
  5.  
  6. //form data
  7. $fullname = strip_tags($_POST['fullname']);
  8. $username = 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.     if($fullname && $username && $password && $repeatpassword){
  15.        
  16.         if($password==$repeatpassword){
  17.             if(strlen($username)>25||strlen($fullname)>25){
  18.                 echo "Name or username is too long.";
  19.             }
  20.             else{
  21.                 if(strlen($password)>25||strlen($password)<4){
  22.                     echo "Password must be between 4 and 25 characters";
  23.                 }
  24.                 else{
  25.                     $password = md5($password);
  26.                     $repeatpassword = md5($repeatpassword);
  27.                    
  28.                     $connect = mysql_connect("localhost","root","");
  29.                     mysql_select_db("phplogin");
  30.                    
  31.                     $queryreg = mysql_query("INSERY INTO users VALUE ('','$fullname','$username','$password','$date')");
  32.                    
  33.                     die("Registration succesfull! <a href='index.php'>Click here</a> to login.");
  34.             }
  35.             }
  36.         }
  37.         else
  38.             echo "Your passwords do not match.";       
  39.     }
  40.     else
  41.         echo "Please fill in ALL fields";
  42. }
  43.  
  44. ?>
  45. <p>
  46. <html>
  47. <form action="register.php" method="post">
  48. <table>
  49. <tr>
  50. <td>
  51. Your name:
  52. </td>
  53. <td
  54. <input type="text" name="fullname" value="<? echo $fullname; ?>">
  55. </td>
  56. </tr>
  57. <tr>
  58. <td>
  59. Username:
  60. </td>
  61. <td>
  62. <input type="text" name="username" value="<? echo $username; ?>">
  63. </td>
  64. </tr>
  65. <tr>
  66. <td>
  67. Password:
  68. </td>
  69. <td>
  70. <input type="password" name="password">
  71. </td>
  72. <tr>
  73. <td>
  74. Password again:
  75. </td>
  76. <td>
  77. <input type="password" name="repeatpassword">
  78. </td>
  79. </tr>
  80. </tr>
  81. </table>
  82. <p><input type="submit" name="submit" value="Register">
  83. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement