login.php 761 Bytes
<?php

session_start();
require_once 'include/DB_Functions.php';
$db = new DB_Functions();

if (isset($_POST['username']) && isset($_POST['password'])) {

    // receiving the post params
    $username = $_POST['username'];
    $password = $_POST['password'];

    // get the user by username and password
    $user = $db->getUserByLoginAndPassword($username, $password);

    if ($user != false) {
      //use is found
        $_SESSION['name'] = $user['name'];
	    header('Location: workArea.php');
    } else {
        // user is not found with the credentials
        die ("username credentials are wrong. Please try again!");
    }
} else {
    // required post params is missing
    die ("Required parameters username or password is missing!");
  
}
?>