nedjelja, 9. prosinca 2007.

redirect a visitor to http://www.example.com

Here's an example on how to redirect a visitor to http://www.newpage.com/

header('Location: http://www.newpage.com/');
?>


The above example shows how to redirect the visitor to a static address. You can also dynamically create the location to which the visitor is to be redirected.

$domain="http://www.google.com/search?q=";
$querystring="vinu%20thomas";
$redirectstr= $domain.$querystring;
header('Location:'. $redirectstr);
?>


The above code will create the URL for redirection as http://www.google.com/search?q=vinu%20thomas and then redirect them to the URL. You can also build php code which can conditionally redirect a page. See how this is done in the following example.

if($user==="Admin")
{
header('Location:admin.php');
}
else
{
header('Location:login.php');
}
?>

Nema komentara:

 

Sopranos Ruby Css Xhtml Cgi Asp.net Calabria Rocky Oktoberfest Fencing