LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 07-11-2008, 03:02 PM   #1
genderbender
Member
 
Registered: Jan 2005
Location: US
Distribution: Centos, Ubuntu, Solaris, Redhat
Posts: 396

Rep: Reputation: 31
Desperate for help with a PEAR login form - need this on one page


Hi all, this is a bit of a last resort as I've seen web based programming questions rarely get noticed on this site, I really am desperate though, I've asked a bunch of other forums and i've been completely ignored or provided with useless ideas.

Basically I have 2 pages, a login page which has 2 fields, email and passwords. The second page is an error checking page which does 2 things - it sends the details via PEAR to a seperate server and awaits a response, if theres an error (e.g NO_EMAIL, NO_PASSWORD, ACCOUNT_LOCKED) then a 'friendlier' message is displayed on the error checking page. What I REALLY want is just one page, the login page to do the error checking and then get sent to a completely seperate page. I've enclosed some of the error checking page for people to view (theres lots of coding missing here and this does work 100% before people comment on that):

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;
This is just a bit of conditional error checking. If anyone has any examples or pages which may be of use please help. Not bothered how this is coded or how errors come up, just need some help.

Last edited by genderbender; 07-11-2008 at 03:05 PM.
 
Old 07-11-2008, 07:36 PM   #2
graemef
Senior Member
 
Registered: Nov 2005
Location: Hanoi
Distribution: Fedora 13, Ubuntu 10.04
Posts: 2,379

Rep: Reputation: 148Reputation: 148
Not certain by what you mean by "I've seen web based programming questions rarely get noticed on this site".

But anyway let's move on. The concept of a page is fairly fluid so I'm not totally certain what your are requesting but in similar situations rather than having echo statements, I store the strings in a variable then when I am ready to send the data back to the client I echo out the whole string. This helps to make the code more flexible in that it can be used in a variety of settings a login screen on its own an login embedded within a div the same code can also be implemented in an Ajax driven site.

So your above code can be run and if you are in the if (error condition) then you can append the login screen code (which I would have placed in a function making it a simple call) to the string.
 
Old 07-12-2008, 12:11 AM   #3
genderbender
Member
 
Registered: Jan 2005
Location: US
Distribution: Centos, Ubuntu, Solaris, Redhat
Posts: 396

Original Poster
Rep: Reputation: 31
I just meant questions about HTML or SQL or PHP or any web based language don't usually get a response from many programming forums. They seems less popular than languages like C++, java etc.

Anyway the idea behind this is to have my error catching code and my login page on a single page, then if there are no errors send the user off to an accounts page. I just want the error codes on the same page and not moving from one page, to another and then to another as this is a) ugly, b)slow(ish).

Thanks for your help anyway, I'll keep on working at it. Guess I'll need a do while loop or something, I've no idea where to start.
 
Old 07-12-2008, 01:23 AM   #4
graemef
Senior Member
 
Registered: Nov 2005
Location: Hanoi
Distribution: Fedora 13, Ubuntu 10.04
Posts: 2,379

Rep: Reputation: 148Reputation: 148
As I understand your problem you don't need a while loop, roughly you could structure you code as follows:
Code:
IF there are login values in the $_POST THEN
|  attempt to authorise the user
|  IF there are errors THEN
|  |  Set up an error string
|  |  Set up the login Form
|  ELSE
|  |  Display the accounts data
|  ENDIF
ELSE
|  Set up the login Form
ENDIF
Since you are setting up the login form twice you can put that code into a function.
You would also need to consider what to do if the user is already logged in (check on a session variable and go directly to the appropriate accounts data page)
 
Old 07-12-2008, 12:30 PM   #5
genderbender
Member
 
Registered: Jan 2005
Location: US
Distribution: Centos, Ubuntu, Solaris, Redhat
Posts: 396

Original Poster
Rep: Reputation: 31
Ahhh, thanks. So where does the form go, PHP_SELF? Then loginvalid (or whatever) if there are no errors. As the errors are generated on a seperate server this is the confusing bit. Anyway thanks a lot, i'll work on it more tonight and see how i get on
 
Old 07-13-2008, 12:17 AM   #6
genderbender
Member
 
Registered: Jan 2005
Location: US
Distribution: Centos, Ubuntu, Solaris, Redhat
Posts: 396

Original Poster
Rep: Reputation: 31
Thought I'd add this to help people understand, I realise the data must be sent to someone else to do the error processing, what I can settle with is a response sent back to the login page with details. At the moment I have my error checking page, and I've made an if statement which basically echoes the entire site and has some error information in the middle, hideous way of doing it. I've been trying to pass an html variable to a page listing errors, but I don't know how to do that without a submit button (I'm kind of new to pure HTML coding.

Heres the flowchart:
http://img228.imageshack.us/img228/9965/errorkz7.jpg

hopefully i'll get a thumbs up for making this and helping people understand what I'm trying to do
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Desperate ! Login Prompt Missed ! DOTT.EVARISTI Linux - Software 5 07-29-2007 09:06 AM
CURL displays the same form as result page swiftguy121 Linux - Software 0 06-02-2007 08:52 AM
install Pear Net/SMTP, Pear Log and Pear DB modules cccc Debian 0 02-26-2007 08:33 AM
javascript html link in a form to not reload page true_atlantis Programming 4 10-26-2006 08:49 AM
Kicking off a script form a web page Hazzie Programming 2 04-26-2004 01:09 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:22 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration