I have problems with login, session and displaying logged in user info

I am new at this and need it for my senior project. I cant figure out what i am doing wrong or where to go. I have gone to other tutorials and sites and nothing is working.
Login.php
[php]<?PHP
error_reporting(9);

require_once("./include/membersite_config.php");
if(isset($_POST[‘submitted’]))
{

$users[‘admin’] = array(‘password’ => ‘admin’, ‘redirect’ => ‘admin.php’);
$users[$username] = array(‘password’ => $password, ‘redirect’ => ‘login-home.php’);

if(array_key_exists($_POST[‘username’],$users)) {
if($_POST[‘password’] == $users[$_POST[‘username’]][‘password’]) {
$_SESSION[‘loggedIn’] = true;
header(‘Location:’.$users[$_POST[‘username’]][‘redirect’]);
exit();
}

}

if($fgmembersite->Login())
{
$fgmembersite->RedirectToURL(“login-home.php”);
}
}

?>[/php]
Login-home.php
[php]}
//Validate there is a user
if($result) {
if($num_rows == 1) {
session_start();
$_SESSION[‘login’] = ‘1’;
header(“location: …/login_success.php”);

        } else {
            session_start();
            $_SESSION['login'] = "";
            header("location: ../login_fail.php");

        }
    } else {
        $error_msg = "Error Validating User! -1";
    }

?>[/php]

Please help me!!!

one problem i see is that $users[$_POST[‘username’] doesn’t exist. you’re assigning that to the person’s actual username ($users[$username]). You have an extra ] in the array key test. needs to be at the end instead of the middle. Im also thinking you need to use a foreach loop to process those arrays.

Do you have to do it like that or is that just what you found in the tutorials?

Sponsor our Newsletter | Privacy Policy | Terms of Service