Browser Identification Code not working
Posted: Fri Jul 01, 2005 5:16 pm
Hello,
I am using PHP code to try and indentify browser and platform, but it doesn't seem to be working.
No matter what browser I use, I just get a msg stating "unidentified browser". I am sure there is a problem with the code. Here it is:
the page can be found at http://www.inspired-evolution.com/Brows ... cation.php
Thanks in advance for any assistance.
I am using PHP code to try and indentify browser and platform, but it doesn't seem to be working.
No matter what browser I use, I just get a msg stating "unidentified browser". I am sure there is a problem with the code. Here it is:
Code: Select all
<?php $viewer = getenv ( "HTTP_USER_Agent:" );
$Browser ="an unidentified browser";
if (preg_match( "/MSIE/i", $viewer ) )
{$browser="Internet Explorer"; }
else if (preg_match( "/Netscape/i", $viewer ) )
{$browser="Netscape"; }
else if (preg_match( "/Opera/i", $viewer ) )
{$browser="Opera"; }
else if (preg_match( "/Mozilla/i", $viewer ) )
{$browser="Mozilla"; }
else if (preg_match( "/Firefox/i", $viewer ) )
{$browser="Firefox"; }
else if (preg_match( "/Mozilla/i", $viewer ) )
{$browser="Mozilla"; }
$platform = "an unidentified operating system" ;
if ( preg_match( "/Windows/i", $viewer ) )
{ $platform="windows"; }
else if(preg_match( "/Macintosh/i" , $viewer ) )
{ $platform ="Macintosh"; }
echo ( "<p>You're using $browser on $platform</p>" );
?>Thanks in advance for any assistance.