Forum Moderators: coopster
I have a link to a long in page on a site that uses sessions. First time round it works fine. If I happen to click the link again it throws an error.
Undefined index: username /url
This is one of the lines:
$user = verify_login($HTTP_POST_VARS["username"], $HTTP_POST_VARS["password"]);
I suspect this is something to do with the form checking. Is there a way around this?
Regards
[edited by: ukgimp at 3:28 pm (utc) on Feb. 28, 2003]
the error message 'undefined error username' means, that the http_post_vars['username'] is not set. are you shure, the var is passed via form and post method?
i think not.
if you're using sessions, then right after logging set a session var that a user logged successfully in. if a user is logged in (ie the session var is set), then don't check for http_post_vars['username'] any longer.
are you with me?
Shamefully, no not really :)
The thing works in that the session is set once the username and password are varified against the DB. The problem comes when reclicking the link in the standard navigations to the same page without actually fillingin form data, subsequently it does not have any form variables and throws an error.
if(!session_is_registered( "username" ) ){
$user = verify_login($HTTP_POST_VARS["username"], $HTTP_POST_VARS["password"]);
}
Essentially, if the session isn't already registered then check for the post vars. If the session is already registered you can skip it or check for something different.