Browser Detector...


Easy tutorial to find out if your user is using FireFox or Internet Explorer.
PHP Code
  1. <?php
  2. $browser = $_SERVER['HTTP_USER_AGENT']; //gets the browser
  3.  
  4. if($browser == 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.3) Gecko/20070309 Firefox/2.0.0.3') {
  5. echo "Mozilla FireFox";
  6. }
  7.  
  8. if($browser == 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727; InfoPath.2)') {
  9. echo "Internet Explorer";
  10. }
  11. ?>


Simple enough, you can add others if you which, but those are the two most used. I hope this comes in handy!
Diablosblizz's Avatar
Views:
2,825
Rating:
Posted on Sunday 23rd September 2007 at 08:40 PM
darklight19
darklight19's Avatar
This won't work if you have a tool bar installed that renames the user agent.
Posted on Thursday 24th May 2007 at 11:58 PM
ShadowMage
ShadowMage's Avatar
no prob
Posted on Thursday 24th May 2007 at 11:40 PM
Jon
Jon's Avatar
nvm fixed it, I changed the "en-US" to "en-GB"...

Thanks guys.
Posted on Thursday 24th May 2007 at 11:37 PM
Jon
Jon's Avatar
Yes
Posted on Thursday 24th May 2007 at 11:32 PM
ShadowMage
ShadowMage's Avatar
it works for me also, does your host support PHP?
Posted on Thursday 24th May 2007 at 11:15 PM
Jon
Jon's Avatar
I'm on Firefox.
Posted on Thursday 24th May 2007 at 05:44 AM
SkillMaster
SkillMaster's Avatar
Works fine for me. what browser are you using it seems to work fine in IE and mozilla for me.
Posted on Wednesday 23rd May 2007 at 09:21 PM
Jon
Jon's Avatar
Basically, nothing shows up when I go on it:

https://scription.net/browser.php
Posted on Friday 18th May 2007 at 09:45 PM
SkillMaster
SkillMaster's Avatar
Yes it does work for me. :S what is your exact problem?
Posted on Thursday 17th May 2007 at 11:35 PM
Diablosblizz
Diablosblizz's Avatar
Could you please say whats wrong? I tested it before I tried. It works with both Internet Explorer and Firefox - as the other browsers (Opera, and NetScape) will NOT work.

Please specify whats wrong and if there is an error.