Guest User

Untitled

a guest
Mar 3rd, 2018
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.55 KB | None | 0 0
  1. <?php
  2. if (isset($_POST['submit']))
  3. {
  4.     $submit = $_POST["submit"];
  5.     $fullname = strip_tags($_POST["fullname"]);
  6.     $username = strip_tags($_POST["username"]);
  7.     $password = strip_tags($_POST["password"]);
  8.     $repeatpassword = strip_tags($_POST["repeatpassword"]);
  9.     $date = date("Y-m-d");
  10.  
  11.     if($submit)
  12.     {
  13.         //check for existence
  14.         if($fullname&&$username&&$password&&$repeatpassword)
  15.         {
  16.             //check if passwords match
  17.             if($password==$repeatpassword)
  18.             {
  19.                 //check length of username
  20.                 if(strlen($fullname)>25||strlen($username)>25)
  21.                 {
  22.                     echo "max limit for username/fullname is 25 characters";
  23.                 }
  24.                 else
  25.                 {
  26.                     //check password length
  27.                     if((strlen($password)<6)||(strlen($password)>25))
  28.                     {
  29.                         echo "password must be between 6 and 25 characters";
  30.                     }
  31.                     else //register the user
  32.                     {
  33.                         //encrypt passwords
  34.                         $password = md5($password);
  35.                                    
  36.                         //open database
  37.                         $connect = mysql_connect("localhost","root","rootpass");
  38.                        
  39.                         //select database
  40.                         mysql_select_db("phplogin");
  41.                        
  42.                         //insert data into the database
  43.                         $queryreg = mysql_query("INSERT INTO users VALUES ('','$fullname','$username','$password','$date')");
  44.                        
  45.                         //notify user that they have been registered
  46.                         die("registered<br><a href='index.php'>return to login page</a>");
  47.                     }
  48.                 }
  49.             }
  50.             else
  51.             {
  52.                 echo "passwords do not match";
  53.             }
  54.         }
  55.         else
  56.         {
  57.             echo "complete all fields to register<br>";
  58.         }
  59.     }
  60. }
  61.  
  62.  
  63. ?>
  64.  
  65. <html>
  66. <head>
  67. <title></title>
  68. </head>
  69. <body>
  70. <h1>Register</h1>
  71. <form action='register.php' method='POST'>
  72.     <table>
  73.         <tr>
  74.             <td>
  75.                 fullname:
  76.             </td>
  77.             <td>
  78.                 <input type='text' name='fullname'>
  79.             </td>
  80.         </tr>
  81.         <tr>
  82.             <td>
  83.                 username:
  84.             </td>
  85.             <td>
  86.                 <input type='text' name='username'>
  87.             </td>
  88.         </tr>
  89.         <tr>
  90.             <td>
  91.                 password:
  92.             </td>
  93.             <td>
  94.                 <input type='password' name='password'>
  95.             </td>
  96.         </tr>
  97.         <tr>
  98.             <td>
  99.                 repeat password:
  100.             </td>
  101.             <td>
  102.                 <input type='password' name='repeatpassword'>
  103.             </td>
  104.         </tr>
  105.         <tr>
  106.         <td>
  107.             <!-- empty -->
  108.         </td>
  109.         <td align="right">
  110.             <input type='submit' name='submit' value='register'>
  111.         </td>
  112.     </tr>
  113.     </table>
  114. </form>
  115. </body>
  116. </html>
Add Comment
Please, Sign In to add comment