Advertisement
Guest User

Untitled

a guest
Jul 19th, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.84 KB | None | 0 0
  1. <?php
  2. require_once '../includes/class.session.php';
  3. require_once '../includes/function.php';
  4. require_once '../includes/class.user.php';
  5.  
  6. if ($session->isLoggedIn()) {
  7.     redirectTo("index.php");
  8. }
  9.  
  10. if (isset($_POST['username'])) {
  11.     $username = trim($_POST['username']);
  12.     $password = trim($_POST['password']);
  13.  
  14.     // Check database to see if username/password exist.
  15.     $user = User::authenticate($username, $password);
  16.  
  17.     if ($user) {
  18.         $session->login($user);
  19.         redirectTo("index.php");
  20.     } else {
  21.         echo "FEJL";
  22.     }
  23. }
  24. ?>
  25.  
  26. <form action="<?php echo $_SERVER['PHP_SELF'];?>" method="post">
  27.     Username: <input type="text" name="username" maxlength="30" /> <br />
  28.     Password: <input type="text" name="password" maxlength="30" /> <br />
  29.     <input type="submit" name="login" value="Login" />
  30. </form>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement