Re: Redirecting users

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Actually, that's not what the "Header Information already sent" comes
from.  It comes from the script already sending output to thet browser 
before the header function is called.  There are a couple of solutions 
to this.

1)  Don't have any white-space in your script before
the <?php

2)  Don't output (echo, print, etc) anything before
you call the header function.

3)  If you can't do the first 2, then you can turn on
output buffering.  This will hold all the output until you say it
should be printed.  This will let the headers go before any content.

The "Header Information already sent" message should usually be 
accompanied by a message telling you on which line the output began.  
This should give you a hint as to what needs to be done to satisfy #1 
and #2.

Dave

--- In php-objects@yahoogroups.com, John Shanyinde <solavar@b...> wrote:
> Problems with 'Header Information already sent'?
> Solution...Don't use Location: etc, etc
> 
> For example, instead of:
> if($username=="admin")
> {
>       header("location: admin/index.php");
> }
>   elseif($username=="user")
> {
>       header("location: user/index.php");
> }
> 
> You can safely say:
> if($username=="admin")
> {
>       echo '<meta http-equiv="refresh" content="0; url=
admin/index.php">';
>       exit;
> }
>   elseif($username=="user")
> {
>      echo '<meta http-equiv="refresh" content="0; url=
user/index.php">';
>      exit;
> }
> 
> Hope this helps,
> 
> John
> 
> 
> 
> 
> 
> 
> At 14:21 06/03/2004, you wrote:
> 
> >Lungo,
> >
> >You also need to make sure that no page (html) information is
placed in the
> >buffer prior to the header location function.  I have found little
things
> >like a blank line prior to the first <? can have his result.
> >
> >Bob
> >
> >-----Original Message-----
> >From: Juma Lungo [mailto:jlungo@y...]
> >Sent: Saturday, March 06, 2004 2:04 AM
> >To: php-objects@yahoogroups.com
> >Subject: Re:  Redirecting users
> >
> >
> >i am using a session in this page.
> >but thanks i can see now i am very close to solve the problem
> >Lungo
> >
> >"Tulga.G" <tulga@n...> wrote:
> >Do u use any header function before this header function? or session?
> >----------------------------------------------------------------
> >Created by Tulga.G
> >Powered by Netsoft Co.,Ltd
> >Copyright 2003-2004. All rights reserved.
> >----- Original Message -----
> >From: "Juma Lungo"
> >To:
> >
> >Sent: Saturday, March 06, 2004 3:36 PM
> >Subject: Re:  Redirecting users
> >
> >
> >Thanks Tulga, but this is not working. It gives an error that
header already
> >sent. where should i put these codes?
> >Lungo
> >
> >"Tulga.G" wrote:
> >Hi, I mean
> >
> >if($username=="admin") {
> >header("location: admin/index.php");
> >} elseif($username=="user"){
> >header("location: user/index.php");
> >}
> >
> >-------------------------------------------------
> >Created by Tulga.G
> >Powered by Netsoft Co.,Ltd
> >Copyright 2003-2004. All rights reserved.
> >----- Original Message -----
> >From: "Juma Lungo"
> >To:
> >
> >Sent: Saturday, March 06, 2004 3:13 PM
> >Subject:  Redirecting users
> >
> >
> >
> >Hi
> >
> >my PhP database driven website is using a login form as a measure of
> >redirecting users and administrators. The login is working
perfectly but the
> >problem is i cant redirect the users so that admin should go the
the admin
> >page and user should go to user pager, any one to help?
> >
> >Lungo




------------------------ Yahoo! Groups Sponsor ---------------------~-->
Buy Ink Cartridges or Refill Kits for your HP, Epson, Canon or Lexmark
Printer at MyInks.com. Free s/h on orders $50 or more to the US & Canada.
http://www.c1tracking.com/l.asp?cid=5511
http://us.click.yahoo.com/mOAaAA/3exGAA/qnsNAA/saFolB/TM
---------------------------------------------------------------------~->

Look here for Free PHP Classes of objects:
http://phpclasses.UpperDesign.com/ 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
     http://groups.yahoo.com/group/php-objects/

<*> To unsubscribe from this group, send an email to:
     php-objects-unsubscribe@yahoogroups.com

<*> Your use of Yahoo! Groups is subject to:
     http://docs.yahoo.com/info/terms/
 


[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Soap]     [Kernel Newbies]     [Yosemite]     [Yosemite Campsites]

  Powered by Linux