Guest User

Untitled

a guest
Mar 3rd, 2018
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.50 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 = md5(strip_tags($_POST["password"]));
  8.     $repeatpassword = md5(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.                         //open database
  34.                         $connect = mysql_connect("localhost","root","rootpass");
  35.                        
  36.                         //select database
  37.                         mysql_select_db("phplogin");
  38.                        
  39.                         //insert data into the database
  40.                         $queryreg = mysql_query("INSERT INTO users VALUES ('','$fullname','$username','$password','$date')");
  41.                        
  42.                         //notify user that they have been registered
  43.                         die("registered<br><a href='index.php'>return to login page</a>");
  44.                     }
  45.                 }
  46.             }
  47.             else
  48.             {
  49.                 echo "passwords do not match";
  50.             }
  51.         }
  52.         else
  53.         {
  54.             echo "complete all fields to register<br>";
  55.         }
  56.     }
  57. }
  58.  
  59.  
  60. ?>
  61.  
  62. <html>
  63. <head>
  64. <title></title>
  65. </head>
  66. <body>
  67. <h1>Register</h1>
  68. <form action='register.php' method='POST'>
  69.     <table>
  70.         <tr>
  71.             <td>
  72.                 fullname:
  73.             </td>
  74.             <td>
  75.                 <input type='text' name='fullname'>
  76.             </td>
  77.         </tr>
  78.         <tr>
  79.             <td>
  80.                 username:
  81.             </td>
  82.             <td>
  83.                 <input type='text' name='username'>
  84.             </td>
  85.         </tr>
  86.         <tr>
  87.             <td>
  88.                 password:
  89.             </td>
  90.             <td>
  91.                 <input type='password' name='password'>
  92.             </td>
  93.         </tr>
  94.         <tr>
  95.             <td>
  96.                 repeat password:
  97.             </td>
  98.             <td>
  99.                 <input type='password' name='repeatpassword'>
  100.             </td>
  101.         </tr>
  102.         <tr>
  103.         <td>
  104.             <!-- empty -->
  105.         </td>
  106.         <td align="right">
  107.             <input type='submit' name='submit' value='register'>
  108.         </td>
  109.     </tr>
  110.     </table>
  111. </form>
  112. </body>
  113. </html>
Add Comment
Please, Sign In to add comment