 <?php
if(isset($_POST['submit'])){
    $dbHost = "localhost";        //Location Of Database usually its localhost
    $dbUser = "******";            //Database User Name
    $dbPass = "******";            //Database Password
    $dbDatabase = "users";    //Database Name
    
    $db = mysql_connect($dbHost,$dbUser,$dbPass)or die("Error connecting to database.");
    //Connect to the databasse
    mysql_select_db($dbDatabase, $db)or die("Couldn't select the database.");
    //Selects the database
    
    /*
    The Above code can be in a different file, then you can place include'filename.php'; instead.
    */
    
    //Lets search the databse for the user name and password
    //Choose some sort of password encryption, I choose sha256
    //Password function (Not In all versions of MySQL).
    $username = mysql_real_escape_string($_POST['username']);
    $password = hash('sha256', mysql_real_escape_string($_POST['password']));
    $sql = mysql_query("SELECT * FROM users_table 
        WHERE username='$username' AND
        password='$password'
        LIMIT 1");
    if(mysql_num_rows($sql) == 1){
        $row = mysql_fetch_array($sql);
        session_start();
        $_SESSION['username'] = $row['username'];
        $_SESSION['fname'] = $row['first_name'];
        $_SESSION['lname'] = $row['last_name'];
        $_SESSION['logged'] = TRUE;
        header("Location: film2.php"); // Modify to go to the page you would like
        exit;
    }else{
        header("Location: log-in.php");
        exit;
    }
}else{    //If the form button wasn't submitted go to the index page, or login page
    header("Location: film2.php");    
    exit;
}
?> 