Okay, my situation is I've built 3 functions
loggedin()
not_loggedin()
checkloggin()
and then I did a bunch of if statements to determine which function will be used. Only problem is, even if a situation is not met, the code executes the wrong function. For example, if the user is not logged in, it will give me a mysql error that the query could not be done. Well, obviously because the user is not logged in, so that function was not suppose to execute. Please tell me what's wrong with my decision part of the code
checklogin();
if(isset($logout)) $return='loggedout';
echo $return;
switch($return) {
case
'no':
not_loggedin();
break;
case
"loggedout":
echo "Logged out";
not_loggedin();
break;
case
"yes":
logged_in();
break;
}
explanation:
checklogin determines if the variable $userid is set, and if yes, is it correct with the password. If it's all good, it returns the value 'yes' for $return, if not good, it returns no. If the variable $logout is set, it's suppose to free the variable userid, so that the function not_loggedin is executed because the function checklogin would return a 'no' value. Let me know if you need all the code to figure this one out. thanks