Advertisement
Guest User

Untitled

a guest
Jul 24th, 2018
84
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. session_start();
  3. require_once __DIR__ . '/config.php';
  4. require_once DIR_UTIL . 'dbManager.php';
  5. require_once DIR_UTIL . 'query.php';
  6.  
  7. require_once DIR_UTIL . "sessionUtil.php"; //includes session login
  8. require_once DIR_UTIL . 'utility.php';
  9.  
  10. // Define $username and $password
  11. $username = test_input($_POST["username"]);
  12. $password = test_input($_POST["password"]);
  13.  
  14.  
  15. $error = login($username, $password); // Variable To Store Error Message
  16.  
  17. if($error === null)
  18.     header('location: ./profile.php');
  19. else
  20.     header('location: ./index.php?err=' . $error );
  21.  
  22.  
  23. function login($username, $password){  
  24.  
  25.     if ($username == null || $password == null) {
  26.         return "Inserisci Username e Password.";
  27.     } else {
  28.         echo $password.$username;
  29.         $userID = authenticate($username, $password);
  30.  
  31.         if($userID != -1) {
  32.             setSession($username, $userID);
  33.             return null;
  34.         }
  35.          
  36.     }
  37.  
  38.     return "Username o Password invalidi.";
  39.  
  40. }
  41.  
  42. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement