Page 1 of 1
checking if a user exist
Posted: Sat Jun 12, 2004 5:31 pm
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
Posted: Sat Jun 12, 2004 6:31 pm
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)
Posted: Sat Jun 12, 2004 6:35 pm
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
well i cant use header() beacuse i have out put
Posted: Sun Jun 13, 2004 12:23 am
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
Posted: Sun Jun 13, 2004 1:08 am
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..
Posted: Sun Jun 13, 2004 3:51 am
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.
Posted: Sun Jun 13, 2004 4:26 am
by pelegk2
k thnaks all of u