Advertisement
Guest User

Untitled

a guest
Jul 3rd, 2017
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.93 KB | None | 0 0
  1. <?php
  2. include_once ('library/util.php');
  3. include_once ('library/user.php');
  4.  
  5. $loginError=false;
  6.  
  7. if ($_POST) {
  8.         $username=$_POST['username'];
  9.         $password=$_POST['password'];
  10.         if (authenticate($username,$password)) {
  11.             session_start();
  12.             $_SESSION['name'] = $_POST['username'];
  13.             redirect('index.php'); 
  14.         } else {$loginError=true;}
  15.  
  16. } //ends if ($_POST)
  17.  
  18. // HOMEWORK
  19. // if authentication fails, show them the form and an error
  20. // message to that effect
  21.  
  22. include 'includes/header.php';
  23. ?>
  24.  
  25. <form method="POST" action="login.php">
  26.     <?php
  27.     if ($loginError) {
  28.         echo ("<p class=\"red\">Your user name or password is incorrect, please try again</p>");
  29.         }  
  30.      ?>
  31.     <label for="username">Username</label>
  32.     <input type="text" name="username"/>
  33.     <label for="password">password</label>
  34.     <input type="password" name="password"/>
  35.     <input type="submit"/>
  36. </form>
  37.  
  38.  
  39. <?php include 'includes/footer.php'?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement