PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
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
billyston wrote: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
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' ];
}
We need more information to debug. Did you try header(" Location: index.php"); instead of header(" Location: ".$session -> referrer );. Also can you post the code of your login function ($session->login). Did you add return true to the end of $session -> login?.