Re: I'm a newbie and running php on Linux

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

 



On Wed, 2010-03-31 at 11:32 -0500, King Coffee wrote:

> Hi,
> 
> I ran the following code snippet on Windows IIS 7, in my index.php file and 
> it worked fine. But when run it on Linux, the "die" code is executed.
> 
> Is there an include file or something else I need to to process this on a 
> linux server?
> 
> <?php
> 	echo '<h1>Redirecting... Please Wait</h1>';
> /*
> 	redirect('welcome.html');
> */
> 	if (!headers_sent()) {
> 		header('Location: ' . 'http://auction.househops.com/index.php');
> 	} else {
> 		die('Could not redirect.');
> 	}
> ?>
> 
> 
> Thanks,
> King 
> 
> 


This should never ever redirect. You've got an echo statement as your
first line of code. Once output has been sent to the browser, PHP cannot
send a redirect header, as the default ones get sent with the output.

I think maybe you'd need a Javascript redirect here, but that comes with
a warning that you cannot rely on everyone to have Javascript available
or enabled on their browser. People do turn it off, people do use
plugins such as NoScript, some routers have been known to strip
Javascript from web pages and not ever browser supports all Javascript
(think text browsers, speech and Braille browsers, etc)

Why do you need to echo out a message to the user that the browser is
redirecting anyway? A header redirect will be seamless and the user
shouldn't even notice anything happening except for the URL changing.

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



[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