tags:

views:

47

answers:

2

Hi,

how in php script redirect in to another page? Now i try header, but this don't work - before header() is echo.

This, I do not want to use:

echo "<meta http-equiv='refresh' content='1;URL=?".$link."'>"; 
+3  A: 
  • Use ob_start() to delay the printing, and use header().
  • Redirect using Javascript, this can be done anywhere in the page.
  • Rewrite your code so that you know early on, before anything is printed, whether you want a redirect.
Sjoerd
+1  A: 

You would want to do the following:

header('Location: http://www.someURL.com');

But this must be done before anything is dropped to the output steam. Also you would not want to use

echo "<meta http-equiv='refresh' content='1;URL=?".$link."'>"; 

As it would force the browser to reload your page, effectively rendering it useless if the user is trying to click a link or type something just as it refreshes.

John