How do I block or restrict a particular browser from unregistered users?
<?php
if (eregi("MSIE",getenv("HTTP_USER_AGENT")) ||
eregi("Internet Explorer",getenv("HTTP_USER_AGENT"))) {
Header("Location: https://www.domain.com/ie_reject?;
exit;
}
?>
Will this code work? How do I browser block cod in php scripting language?
Â
How do I browser block code in php?
Â
Hello,
I have a simple example that will show you how to block a browser using PHP. I documented each line for you and here is the code:
<?php
// This line will check what browser the user is using.
$agent = $_SERVER['HTTP_USER_AGENT'];Â
//This line will print to the screen the type of browser the user is using. You can keep the line or delete it .
echo $agentToBlock;
// Allow certain browser and disable others. This is a condition statement used to check if the browser is Internet explorer
if (preg_match("/bMSIEb/i", $agent))Â
{
  echo 'You are using IE, you can pass.';
}Â
 // Other browsers are not allowed
else if (preg_match("/bFirefoxb/i", $agent))
{
  echo 'You are using Firefox, goodbye.';
 // use this function to abort.
  exit();Â
  }
?>
I hope this is useful.