This topic is locked
[SOLVED]

 before login validation

9/10/2013 09:38:53
PHPRunner General questions
C
chrispa author

hi
i use following before login
if($data["flagadmin"] == 0)

{

echo '<center><text style="color:#FF0000;" name="message">Your account is pending for approval by administrator!

We have received your account details <

</text></center>';
return false;

}

else

{

header("Location: main_tracking_list.php");
return true;

}
exit();
alhtough flagadmin is not 0 but 1 for some users still cannot login and redirect to main_tracking_list page
pls help

C
cgphp 9/10/2013

If $data["flagadmin"] is 1 your code will redirect the user to the main_tracking_list.php page.

C
chrispa author 9/10/2013



If $data["flagadmin"] is 1 your code will redirect the user to the main_tracking_list.php page.


THANKS
but either the flagadmin is 0 or 1 still return the false message on both cases

C
cgphp 9/10/2013

Are you talking about the "Before login" event or the "Before registration" event? Is flagadmin a custom field? In the "Before login" event you can only process the username and password fields.

C
chrispa author 9/11/2013



Are you talking about the "Before login" event or the "Before registration" event? Is flagadmin a custom field? In the "Before login" event you can only process the username and password fields.


i see thanks
i try that after succesfull login
global $conn;

$str = "select * from user where user = '".$_SESSION["UserID"]."'";

$rs = db_query($str,$conn);

$data = db_fetch_array($rs);
if ($data["flagadmin"] == 0)

{

header("Location: test.com");

exit();

}

else

{return true;};
but always get invalid login message

C
cgphp 9/11/2013

You don't have to fetch the record from the database.

PHPrunner collects the existing user record of the login table in the $data array.
Remove your code from the "After successfull login" event and enter this code:

if($data["flagadmin"] == 0)

{

header("Location: test.com");

exit();

}

else

{

return true;

}
C
chrispa author 9/11/2013



You don't have to fetch the record from the database.

PHPrunner collects the existing user record of the login table in the $data array.
Remove your code from the "After successfull login" event and enter this code:

if($data["flagadmin"] == 0)

{

header("Location: test.com");

exit();

}

else

{

return true;

}



thanks a lot is working fine