Re: header problem

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

 



On Thu, 2009-09-10 at 09:04 +0200, Sándor Tamás (HostWare Kft.) wrote:
> Usually, when I have to redirect the user AFTER headers has been sent (like 
> showing an error message), I write this:
> 
> <SCRIPT>location=page_to_send.html</SCRIPT>
> 
> But this will redirect the user at once. If you want the user to read the 
> page, you should do something in Javascript with setTimeout(func,timeout) 
> function.
> 
> BR,
> SanTa
> 
> ----- Original Message ----- 
> From: "George Langley" <george.langley@xxxxxxx>
> To: <php-general@xxxxxxxxxxxxx>
> Sent: Thursday, September 10, 2009 8:39 AM
> Subject: Re:  header problem
> 
> 
> > Hi Blueman. As soon as ANYTHING has been drawn to the browser, you  cannot 
> > use a header command. So you need to work through all of your  code, and 
> > ensure that all of your logic that could result in a header  call is run 
> > BEFORE you send any html code. Is going to be tricky if  mixing html and 
> > php calls.
> >
> > George
> >
> >
> > On 10-Sep-09, at 12:27 AM, A.a.k wrote:
> >
> >> hello
> >> I recentrly uploaded my project from localhost to a hosting and  found 
> >> many errors and warnings which didnt have in local. one of the  most 
> >> annoying one is header('Location xxx').
> >> I have used header to redirect users from pages, and kinda used it  alot. 
> >> i know about the whitespace causing warning, but most of the  pages i'm 
> >> sending users got html and php mixed so i'm confused about  how to remove 
> >> whitespace in a html/php file. the error is :
> >> Warning: Cannot modify header information - headers already sent  by ....
> >> here is a simple example, user update page :
> >>    if($valid)
> >>                   {
> >>                       $msg='111';
> >>                       $user->dbupdate();
> >>                        header("Location: /admin/index.php?msg=$msg");
> >>
> >>                   }
> >>                   else
> >>                   {
> >>                        foreach($errors as $val)
> >>                           echo '<p id="error">'.$val.'</p>';
> >>                   }
> >>
> >> and on admin index i get $msg and display it.
> >> <html>
> >> ......
> >> //lots of stuff
> >>  <?php
> >>                  $msg = $_GET['msg'];
> >>                          switch($msg){
> >>                          case '111'       echo '<p> </p>';
> >>                                       break;
> >>                         case '421':...
> >>                   }
> >> ?>
> >> //  more html and php
> >>
> >> how can i fix this?
> >>
> >> -- 
> >> PHP General Mailing List (http://www.php.net/)
> >> To unsubscribe, visit: http://www.php.net/unsub.php
> >>
> >
> >
> > -- 
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> > 
> 
> 
Don't use a timer to redirect if you want the user to read a message, as
this assumes that the visitor is a good reader. This is forgetting all
of those visitors with reading difficulties (i.e. Dyslexia), those users
who have attention problems who can't focus on text for long periods
(i.e. ADHD) and any users who rely on things such as screen readers
(which are slower than reading text yourself (if you're an average
reader!) ) or a Braille browser.

In cases such as these, it's best to let the visitor move at their own
pace and not redirect until they want to.

Thanks,
Ash
http://www.ashleysheridan.co.uk




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux