I have a simple login page with 2 fields (email and password), these details are then sent to another page which processes the inputs and sends them off to a PEAR server and awaits a response, it then comes back with one of 3 values: 5 values (NO_EMAIL, NO_PASSWORD, ACCOUNT_LOCKED, LOGIN_INVALID or a userID, a numerical value). What i really, REALLY want is all this on one page (my login page), instead of 2. So a user logs into a single page, if they mistype their password or something the error code is echoed on the SAME page. i've tried PHP_SELF which won't work for obvious reasons. I've attached a bit of my error checking code for people to look at and get a greater understanding of how the system works. It's just a conditional statement at the moment. The error code is received from a completely seperate PEAR server which we do not own...
Code:
$params = array('email' => $email,'password' => $password,'service' => 'API v1.0');
$auth = $client->call('getAuthToken', $params);
// Check for a fault
if ($client->fault) {
$fault = $auth['faultstring'];
switch ($fault) {
case "NO_EMAIL":
echo 'Email address missing';
break;
case "NO_PASSWORD":
echo "Password missing";
break;
case "LOGIN_INVALID":
echo "email or password is incorrect";
break;
case "ACCOUNT_LOCKED":
echo "The account has been locked.";}
}else {
$err = $client->getError();
if ($err) {
echo 'There seems to be a server side error, please send a ticket along with this refereces: $err to the admin';}
else {
echo header("Location: http://the_page_in_question.com");}
}
exit;
Comment