Guest User

Untitled

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