Vasilena

LoginForm

Mar 29th, 2022
964
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.21 KB | None | 0 0
  1. <?php
  2.     session_start();
  3.     $greshka = false;
  4.     if(isset($_POST['submit'])){
  5.         $username = $_POST['uname'];
  6.         $password = $_POST['psw'];
  7.         if($username == 'Ivan' && $password == '12345678'){
  8.             $_SESSION['logged'] = $username;
  9.             header('location: index.html');
  10.         }else{
  11.             $greshka = 'wrong username';
  12.         }
  13.     }
  14. ?>
  15.  
  16. <form action="loginform.php" method="post">
  17.   <div class="container">
  18.     <label for="uname"><b>Username</b></label>
  19.     <input type="text" placeholder="Enter Username" name="uname" required>
  20.  
  21.     <label for="psw"><b>Password</b></label>
  22.     <input type="password" placeholder="Enter Password" name="psw" required>
  23.  
  24.     <button type="submit" id="submit" name="submit">Login</button>
  25.     <label>                    
  26.       <input type="checkbox" checked="checked" name="remember"> Remember me
  27.     </label>
  28.   </div>
  29.  
  30.   <div class="container" style="background-color:rgb(225, 225, 225)">
  31.     <button type="button" class="cancelbtn">Cancel</button>
  32.     <span class="psw">Forgot <a href="#">password?</a></span>
  33.   </div>
  34. </form>
  35.  
  36. <?php
  37. if($greshka){
  38.  
  39. ?>
  40.     <div>
  41.         <h1><?= $greshka?></h1>
  42.     </div>
  43. <?php
  44. }
  45. ?>
  46.  
  47.  
Advertisement
Add Comment
Please, Sign In to add comment