Page 1 of 1

Forward command

Posted: Fri Apr 19, 2002 6:18 am
by Tony Brush
Hi all,
I'm a PHP newbie.
Have studied manual & searched tutorials without luck...
I need to send the user to a specified URL at a point in code - hyperlinks are not appropriate as it is not to be reliant on user interaction. Is there a command something like Forward("next.htm") ?
Thanks for help,
Tony

Posted: Fri Apr 19, 2002 7:35 am
by Phirus
Use either one of these:

Code: Select all

<?
  header("Location: http://www.example.com/"); 
?>
OR

Code: Select all

<meta http-equiv="refresh" content="0;URL=http://www.example.com">
Hope that helps,

PhIrUs

Posted: Sat Apr 20, 2002 3:43 am
by hex
The header() function will only work at the start of a page (before any content is outputted). You'd have to use JavaScript or something to do it mid-page probably.
I had this script from ages ago:

Code: Select all

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd">
<html>
<head>
<script language="JavaScript1.1">
<!--
location.replace("http://www.new.site/page.html");
//-->
</script>
<noscript>
<meta http-equiv="Refresh" content="0; url="http"://www.new.site/page.html" />
</noscript>
</head>
<body>
This page has moved to a <a href="http://www.new.site/page.html">new location</a>.
</body>
</html>

try and use header...

Posted: Sun Apr 21, 2002 12:54 pm
by romeo
both javascript and meta refresh can be disabled and sometimes are because redirects can be a security risk when playing with personal info.
8O

Posted: Sun Apr 21, 2002 1:22 pm
by jason
If you are having problems with using header() because of the "headers already sent error", look up output buffering in the manual as well as here: http://www.newbienetwork.net/content.php?id=42