Forum Moderators: coopster

Message Too Old, No Replies

Yet, another login question....

         

ramoneguru

4:21 am on Apr 5, 2005 (gmt 0)

10+ Year Member



I have been working on a login page that does not seem to redirect a user to a different page after I check to make sure they are in my database. I started a session on every page (login page included) and tried using the header(Location:page) function for redirection.

Unfortunately header() won't redirect if you already printed output. What way would you recommend to redirect a user to a different page without them actually clicking a button/link?

Basically the login page goes like this:
1. Get user email/pwd
2. Check to see if email is correctly formatted (if it isn't, then keep user at the login page)
3. After making sure email is accurate, submit email/pwd to database
4. If email matches an organization then redirect to an organization page
5. If email matches a member, redirect to the member page

Its part 4/5 that got me stumped...
--Nick

ironik

4:29 am on Apr 5, 2005 (gmt 0)

10+ Year Member



You can do parts 4 and 5 server side since you testing the email in both cases. You could do 2 checks for the email address in your organisation table and your member table.

In psuedo code:

check1, db query to organisation table
check2, db query to member table
if found in organisation
direct to organisation page
else if found in member table
direct to member page
end if

All you'd have to do is decide what takes precedence, and what to do if it's not found in either table.

Just make sure the above checks happen before you send any headers to the page so you can call header('location: ') successfully. If I read you right you had one of them working, but not the second. You won't be able to call it twice...

ramoneguru

5:22 am on Apr 5, 2005 (gmt 0)

10+ Year Member



Yeah, that sounds about right. I was echoing some variables to the screen (error checking purposes) so it was throwing the header error.

I was doing it a little different. Your way sounds a little better though.

ironik

5:37 am on Apr 5, 2005 (gmt 0)

10+ Year Member



Just reading over what I said, just for effeciency purposes, you might want to query one first, then if the email doesn't exist, query the other. Querying both at the top might be a little unecessary.