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!
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.