Link to home
Start Free TrialLog in
Avatar of philbrom
philbrom

asked on

Redirecting a user

Hello,
I would like, depending on their browser version, to redirect users to another URL (say, if their browser won't support layers,...). Anybody can help?
For info, here's the script I have so far written.

<html>
<head>
<title>Test?</title>
<?php    
$r=$HTTP_USER_AGENT;
$regexp="Mozilla/4";
if (ereg($regexp, $r, $reg)) echo "Good!!<p>";
elseif (!ereg($regexp, $r, $reg))
{
Header("Location: http://www.php.net");
}
?>
</head>
<body>

The browser you use is <?php echo $HTTP_USER_AGENT; ?>

</body>
</html>

Why won't it work
Avatar of a.marsh
a.marsh

First thing - you will get a warning because you have given output to the browser before attempting to redirect using a HTTP header....

I honestly think you should do this on the client side - use Javascript.

What browsers do you need to test for and hence redirect to different pages? If you provide the necessary information I can put the javascript together for you.

:o)

Ant
ASKER CERTIFIED SOLUTION
Avatar of Curieux
Curieux

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Use javascript I think it will help you if you want I will provide you code

Harry
Did you read my comment harwantgrewal?

:o\

Ant