Session Variables and Redirecting

From: Date: Fri, 13 Jul 2001 18:35:54 +0000
Subject: Session Variables and Redirecting
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-57781@lists.php.net to get a copy of this message
I've done this on other platforms ASP,Cold Fusion, but I need to know what's the best way to do it on PHP. 1. grab username and password from POST vars. 2. select count(*) from users where username = '$username' and password='$password'... something along these lines 3. if that user exists and password matches, set a flag on the user and send them to the right page, otherwise increment failed attempts and send them back to login page. if (count > 0) session_register("someflag"); $HTTP_SESSION_VARS["someflag"] = somevalue; header("Location: secretpage.php"); } else session_register("failedattempts"); $HTTP_SESSION_VARS["failedattempts"]++; header("Location: loginpage.php"); } but apparently, i can't start/register a session and then redirect. Is there a better way to do this? Regards, Johnny

« previous php.general (#57781) next »