This topic is locked
[SOLVED]

login

5/1/2021 7:20:15 AM
PHPRunner General questions
I
I author

I added an "allowed" field to the users table. By setting this field to true or false, I can determine if the user can log into the program. Which code can I use for this? What event should this code be in? Can I find an example somewhere? Thanks in advance.

D
david22585 5/1/2021

Events -> Before Login

$_SESSION["login_msg"] = "";
$rs = DB::Query("SELECT allowed FROM user_table WHERE username = '".$username."'");
$data = $rs->fetchAssoc();
if ($data["allowed"] == "0"){
$message = "Your profile is not allowed";
return false;
} else {
return true;
}

The session is to give the user some kind of feedback about their failed login. So go to the Events -> Login Page: Before Process and add the following code to display the message:

echo $_SESSION["login_msg"];
unset($_SESSION["login_msg"]);
I
I author 5/2/2021

Great ! Works fine.