I'm trying to create a page that will redirect users depending on their operating system. To begin with I need it to work redirecting Windows XP users to place A, other Windows users to place B and Mac users to place C.
I used this to determine Windows/Mac which worked fine:
<?php
$useragent = $_SERVER['HTTP_USER_AGENT'];
if (strstr($useragent,'Win')) {
$os='<META HTTP-EQUIV="Refresh"
CONTENT="1; URL=windows.php">';
} else {
$os='<META HTTP-EQUIV="Refresh"
CONTENT="0; URL=mac.php">';
}
print "$os";
?>
Which worked fine, but then I tried to add a statement for Windows NT 5.1 (Windows XP)
<?php
$useragent = $_SERVER['HTTP_USER_AGENT'];
if (strstr($useragent,'Windows NT 5.1')) {
$os='<META HTTP-EQUIV="Refresh"
CONTENT="1; URL=windows-xp.php">';
} else if (strstr($useragent,'Win')) {
$os='<META HTTP-EQUIV="Refresh"
CONTENT="1; URL=windows.php">';
} else {
$os='<META HTTP-EQUIV="Refresh"
CONTENT="0; URL=mac.php">';
}
print "$os";
?>
I'm not convinced I'm doing this the best way, but any help thrown at me would be much appreciated.
Thanks!