问题描述:

I was curious to know if there was another way than using javascript to make php go to another page ?

Because head only works when it is the first function to be called, so I resorted to javascript to go to another page. But php must have a similar function no ?

 <?php session_start();

session_destroy();

echo '<script language="JavaScript">

<!--

window.location="home.php";

//-->

</script>';

?>

网友答案:

You have a mistake.

header('Location: some_location.php');

Needs to be the first things that's being output, meaning, if you echo anything before this, it wont work, other wise it will work.

So just:

header('Location: some_location.php');
网友答案:

Try

<?php 
    header('Location: error.php');
?>

For more info: php manual header function

Cleber.

网友答案:

You need to modify the header of your HTTP Response with the function header in php

http://www.php.net/manual/function.header.php

<?php
header("Location: home.php")
?>

Also you can add a particular header used by the browser. for example if your page has moved permanently, you can use:

<?php
header('HTTP/1.1 301 Moved Permanently');
header("Location: home.php");
?>

You can see more information about redirection on: http://en.wikipedia.org/wiki/URL_redirection

网友答案:

Sure. You can use a "meta redirect":

http://webdesign.about.com/od/metataglibraries/a/aa080300a.htm

For example:

<meta http-equiv="refresh" content="2;url=http://webdesign.about.com/"> 

相关阅读:
Top