PEAR Forum :: PHP Extension and Application Repository

PEAR Forum Forum Index
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
Self validating form with PEAR error messages

 
Post new topic   Reply to topic    PEAR Forum Forum Index -> Authentication
View previous topic :: View next topic  
Author Message
slowpoke



Joined: 10 Jul 2008
Posts: 1

PostPosted: Thu Jul 10, 2008 2:57 am    Post subject: Self validating form with PEAR error messages Reply with quote

I'm making a login form (email and password) and I've got my pear client getting the data sent by the form, this is then sent to a pear server with some other details and errors are received back e.g if the user refuses to type an email address, the pear client forwards submitted details to the pear server and the server responds to the reply (in this case NO_EMAIL) by writing 'missing email address, please type one in' in a new Window.

Anyway, I really want these error codes echoed to the user on the same page, so when they try to login for example and miss out a dialog box a new page with error messages doesnt appear, thy just get some red text saying you forgot your email on the same page.

Thanks, heres the code that works for seperate pages (obviously server side details have been removed) when it works, it just returns a number, so yeah, just want this on one page.

Code:

$email = $_POST["email"];
$password = $_POST["password"];
$params = array('email' => $email,'password' => $password,'service' => 'API v1.0');
$auth = $client->call('getAuthToken', $params);

if ($client->fault) {
       $fault = $auth['faultstring'];
                switch ($fault) {
                case "NO_EMAIL":
                echo 'Please type in your email';
                break;
                case "NO_PASSWORD":
                echo "Please type in your password";
                break;
                case "LOGIN_INVALID":
                print_r($fault);
                echo "Email/password mismatch";
                break;
                case "ACCOUNT_LOCKED":
                echo "The account has been locked";}
}else {
       $err = $client->getError();
       if ($err) {
                      echo '<h2>Error</h2><pre>' . $err . '</pre>';
       } else {
               print_r($auth);
       }
}

exit;
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    PEAR Forum Forum Index -> Authentication All times are GMT + 2 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum



PEAR Forum topic RSS feed 
Powered by phpBB © 2001, 2005 phpBB Group

Provided by Ministry of Web developement

'Actiemonitor' online projectmanagement software