Hey, I've been trying to get a browser based redirect working for a new site I'm designing. Basically I'm trying to point older browsers to a different skin of my site. I've found some code that should do this, but it comes with no instructions as to how to use it. Having tried it in various different ways I keep on turning up errors on one line. The Code is...
<?php
// Redirect to:__(must have trailing slash)
$redirect_uri = "http://www.iamsparticus.co.uk/";
// Page extension: (.htm .html .php .shtml etc)
$extension = ".php";
// start:
if ($name = strstr ($HTTP_USER_AGENT, "OPERA")) {
____$browser = "opera"; //this is the line it throws out as an error
________}
elseif ($name = strstr ($HTTP_USER_AGENT, "MSIE")) {
____$browser = "ie";
________}
elseif ($name = strstr ($HTTP_USER_AGENT, "WebTV")) {
____$browser = "webtv";
________}
elseif ($name = strstr ($HTTP_USER_AGENT, "Mozilla/4")) {
____$browser = "nn4";
________}
elseif ($name = strstr ($HTTP_USER_AGENT, "Mozilla/5")) {
____$browser = "nn6";
________}
elseif ($name = strstr ($HTTP_USER_AGENT, "Lynx")) {
____$browser = "lynx";
________}
elseif ($name = strstr ($HTTP_USER_AGENT, "w3m")) {
____$browser = "w3m";
________}
else { $browser = "unknown";
________}
________
// redirect location
Header ("Location: $redirect_uri"."$browser"."$extension");
?>
If I alter the order of the browsers it still always throws out the first "$browser" part of the code.
Anyone know why this happens, or perhaps can redirect me to a better browser redirect script?