[SOLVED] checking if a user exist

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
pelegk2
Forum Regular
Posts: 633
Joined: Thu Nov 27, 2003 5:02 am
Location: Israel - the best place to live in after heaven
Contact:

checking if a user exist

Post by pelegk2 »

i need to check if a user exist and if not to redirect him to a certain page
how do i do thatT?
i cant use includes and i know it a problem to use
Header(Location:index.php)
if its not written in the first line so what the best way to do?
thnaks in advance
peleg
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

it's perfectly fine to use header() later in the file, as long as there hasn't been any output, or you are using output buffering([php_man]ob_start[/php_man] for details)
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

I use:

Code: Select all

<script language="javascript">document.location.href = "http://domain.com";</script>
because you can put it anywhere after output
User avatar
pelegk2
Forum Regular
Posts: 633
Joined: Thu Nov 27, 2003 5:02 am
Location: Israel - the best place to live in after heaven
Contact:

well i cant use header() beacuse i have out put

Post by pelegk2 »

but what abput ob_start()? i read but didnt understand execlly how it helps me :(
can u lighten me?
thnaks in advance
peleg
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

using ob_start you can echo all you like... if you need to use header() it'll get stuck in the output queue in the correct place..

some, myself included, aren't too big of fans of using ob_start.. mostly because we feel it points to a problem in your (figuratively) design..
User avatar
launchcode
Forum Contributor
Posts: 401
Joined: Tue May 11, 2004 7:32 pm
Location: UK
Contact:

Post by launchcode »

Yeah I would agree with that.. there are cases for ob_start, but they are far and few between. Just use a correctly defined Header Location - if you do it right, there isn't a browser out there that will actively not support it - and it can appear anywhere in your PHP script so long as you haven't echo'd anything out by that point.
User avatar
pelegk2
Forum Regular
Posts: 633
Joined: Thu Nov 27, 2003 5:02 am
Location: Israel - the best place to live in after heaven
Contact:

Post by pelegk2 »

k thnaks all of u
Post Reply