Advertisement
Ribang

Login Form With SESSION Without Connect To Database

Feb 4th, 2018
372
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.16 KB | None | 0 0
  1. <?
  2.        
  3.         $username = "xsecurity"; # Here Your Username
  4.        $password = "e10adc3949ba59abbe56e057f20f883e"; # password = 123456
  5.        $user = $_POST['user'];
  6.         $pass = $_POST['pass'];
  7.         $form = "<form method='POST'>
  8.        <center>
  9.        Login Form ! <br>
  10.        <input type='text' name='user'>
  11.        <input type='password' name='pass'>
  12.        <input type='submit' value='Login !'>
  13.        </form>";
  14.        
  15.         session_start();
  16.         if(!isset($_SESSION['sec']))
  17.         {
  18.                 $_SESSION['sec'] = false;
  19.         }
  20.         if(isset($pass))
  21.         {
  22.                 if($user == $username and md5($pass) == $password)
  23.                 {
  24.                         $_SESSION['sec'] = true;
  25.                 }
  26.                 else
  27.                 {
  28.                         die("{$form} <br> Wrong Password :D");
  29.                 }
  30.         }
  31.         if(!$_SESSION['sec']):
  32.         echo $form;
  33.         exit();
  34.         endif;
  35.        
  36.         # Logout
  37.        if($_GET['log'] == 'out')
  38.         {
  39.                 session_destroy();
  40.         }
  41.         echo "Welcome {$user} | <a href='?log=out'>Logout</a>";
  42. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement