I need help with my login script
Posted: Sun Jun 29, 2014 3:40 am
Hi guys, I have this login in scrpt. When logged in it should take the user to index.php but rather stops at process.php. All I want is the user to be redirected to index.php after entering the correct username and password. I have the session script in my classes folder and the process script is in the the root folder as the login.php and index.php. Below is my code
process.php function:
session.php function:
process.php function:
Code: Select all
function procLogin()
{
global $session, $form;
/* Login attempt */
$retval = $session -> login( $_POST['username'], $_POST['password'], isset( $_POST['remember'] ) );
/* Login successful */
if( $retval )
{
header(" Location: ".$session -> referrer );
}
/* Login failed */
else
{
$_SESSION['value_array'] = $_POST;
$_SESSION['error_array'] = $form -> getErrorArray();
header(" Location: ".$session -> referrer );
}
}
session.php function:
Code: Select all
function startSession()
{
global $database; //The database connection
session_start(); //Tell PHP to start the session
/* Determine if user is logged in */
$this -> logged_in = $this -> checkLogin();
/**
* Set guest value to users not logged in, and update
* active guests table accordingly.
*/
if( !$this -> logged_in )
{
$this -> username = $_SESSION['username'] = GUEST_NAME;
$this -> userLevel = GUEST_LEVEL;
$database -> addActiveGuest( $_SERVER['REMOTE_ADDR'], $this -> time );
}
/* Update users last active timestamp */
else
{
$database -> addActiveUser( $this -> username, $this -> time );
}
/* Remove inactive visitors from database */
$database -> removeInactiveUsers();
$database -> removeInactiveGuests();
/* Set referrer page */
if( isset( $_SESSION['url'] ) )
{
$this -> referrer = $_SESSION['url'];
}
else
{
$this -> referrer = "/";
}
/* Set current url */
$this -> url = $_SESSION[ 'url' ] = $_SERVER[ 'PHP_SELF' ];
}