Jump to content

get_browser working in WAMP, but not in LAMP


mattward

Recommended Posts

I have a php page that checks a user's browser, and if they are using any version of IE earlier than 9.0, it tells them they must use a different browser to access the page they are trying to get to.  If their browser is compatible, it just passes them right along to the destination site.  The code works perfectly in my WAMP testing environment, but when I put it on our LAMP server, it doesn't pull the browser info.  Consequently, it passes the user on to the destination site, even if their browser is not compatible.

 

I have configured my php.ini file to point to the correct path for my php_browscap file, and when I look at the php test page, it shows the correct location in the browscap value setting.  Any ideas as to why this would not be working on the LAMP server?  Or any ideas on a better way to accomplish what I am trying to do here?  I am always open to better ideas.

 

Here is the code:

 

------------------------------------------------------------------

 

<?php
 
$browser = get_browser(NULL, TRUE);
 
if($browser["browser"] == 'IE' AND $browser["version"] < 9)
{
echo "Your current internet browser is Internet Explorer Version " . $browser["version"] . ".  ";
echo "In order to use this website, you must either use Google Chrome, Mozilla Firefox, or Internet Explorer 9.0 or higher.";
}
else
{
header("Location: http://myURL");
}
 
?>
 
<html>
<p><a href = "http://www.microsoft.com/ie">Click here to install a current version of Internet Explorer</h></p>
<p><a href = "http://www.mozilla.com/firefox">Click here to install Mozilla Firefox</h></p>
<p><a href = "http://www.google.com/chrome">Click here to install Google Chrome</h></p>
</html>
 
--------------------------------------------------------------------
 
Thanks in advance for any insights!

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.