RE: redirect using php

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

 



If it helps here's the code I use to redirect

<?php
function chrome_redirect($url)
{ // redirect the page
	if (headers_sent())
	{ // perform JS redirect
		echo '<script type="text/javascript"
language="javascript"><!-- document.location.href=\'' . $url . '\'; //
--></script>';
	} else { // no headers sent... much nicer header redirect
		header('location: ' . $url);
		die();
	}
}
?>

HTH

Dan

-----------------------------------------------------
Dan Parry
Senior Developer
Virtua Webtech Ltd
http://www.virtuawebtech.co.uk

-----Original Message-----
From: Mark Kelly [mailto:php@xxxxxxxxxxxxxxx] 
Sent: 05 April 2006 14:19
To: php-general@xxxxxxxxxxxxx
Subject: Re:  redirect using php

On Wednesday 05 April 2006 13:55, Chris Shiflett wrote:
> Mark Kelly wrote:
> > You can also use something like:
> >
> > echo "<meta http-equiv=\"Refresh\" content=\"0;url=$from_page\">";
>
> There's no need to use a meta tag to mimic HTTP headers. PHP provides
> the header() function.

I have been using that method when I got part-way through some processing 
that produces output, and hit something that requires a redirect. As I 
understand it headers are no use to me here.

I'm very much a beginner, so if this is the wrong way to do this, I'd 
appreciate pointers. Thanks for the reply, either way.

Mark

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


__________ NOD32 1.1454 (20060321) Information __________

This message was checked by NOD32 antivirus system.
http://www.eset.com

-- 
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