Develop PHP Website for Learning Web Design Free Online
  Home   |   Forums   |   DevCMS
  Join   |   Log In
 
 


Tutor at Develop PHP
Block any Browser You Want
Programming Category: PHP

Author: Adam      Added: Mar 06, 2010      Views: 814    
Tweet This Page  Post page to Facebook  Post page to Facebook

We recommend you not block any browser because that is website suicide, but if you must block a crappy browser for whatever reason:

<?php

$agent = $_SERVER['HTTP_USER_AGENT']; // Access what browser they are using

if (preg_match("/\bMSIE\b/i", $agent)) {

   echo 'You are using IE, not sweat good buddy, you can pass.';

} else if (preg_match("/\bFirefox\b/i", $agent)) {

   echo 'You are using Firefox, you suck, goodbye.';
   exit(); // exit the script after telling them they suck for using a crap tool for browsing the web 
  
}

?>

To find out the AGENT name for any browser just visit this script yourself while using the browser you wish to block.

<?php

$agentToBlock = $_SERVER['HTTP_USER_AGENT'];
// this will be the agent you want to block

echo $agentToBlock;

?>


Comment on Block any Browser You Want

 
 
Arbitrary Links and Archives
Home
Active Forums
Members
SIte News
Link To Us
Gear
2009 Forum Archive
Programming Courses
Learn HTML
Learn CSS
Learn PHP
Learn MySQL
Learn Javascript
Learn jQuery
Learn ActionScript 3.0
Learn Java
Learn XML
DevelopPHP Requires Flash Player
Get Adobe Flash player
___________________________________________

Terms of Use  •  Privacy  •  Admin Notes

©2010 developphp.com   |   Powered By FlashBuildingHolder