Need some php help

dharmil

New Member
Messages
1,656
Reaction score
0
Points
0
i have made a site but only want users using firefox, ie and opera to be able to view it if they dont have it then they get redirected to another page
can any body helps me out with this

i have some thing but it doesnt work well
PHP:
<?
if (eregi("firefox",$_SERVER['HTTP_USER_AGENT'])){
echo "firefox";
}
if (eregi("ie",$_SERVER['HTTP_USER_AGENT'])){
echo "ie";
}
if (eregi("opera",$_SERVER['HTTP_USER_AGENT'])){
echo "opera";
}
else {
echo "error";
}
?>

but when i use fire fox it still says firefox error
but its not supost to say error
 
Last edited:

Chris Z

Active Member
Messages
5,603
Reaction score
0
Points
36
try just using "HTTP_USER_AGENT", take the "$_SERVER" part off see if that works
 
Last edited:

Bryon

I Fix Things
Messages
8,149
Reaction score
101
Points
48
PHP:
<?php
   $userAgent = 'Filler'. $_SERVER['HTTP_USER_AGENT'];
   if (stripos($userAgent, 'firefox')){
      echo "firefox";
   }
   elseif (stripos($userAgent, 'ie')){
      echo "ie";
   }
   elseif (stripos($userAgent, 'opera')){
      echo "opera";
   }
   else {
      echo "error";
   }
?>
 

LiaoHua

New Member
Messages
6
Reaction score
0
Points
0
As I see:

$_SERVER['HTTP_USER_AGENT'] = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; POTU(1.13))"

And you need to pickup "MSIE".
 

[XiRE]

New Member
Messages
44
Reaction score
0
Points
0
LiaoHua said:
As I see:

$_SERVER['HTTP_USER_AGENT'] = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; POTU(1.13))"

And you need to pickup "MSIE".
PHP:
<?php 
   $userAgent = 'Filler'. $_SERVER['HTTP_USER_AGENT']; 
   if (stripos($userAgent, 'FF')){ 
      echo "firefox"; 
   } 
   elseif (stripos($userAgent, 'MSIE')){ 
      echo "ie"; 
   } 
   elseif (stripos($userAgent, 'opera')){ 
      echo "opera"; 
   } 
   else { 
      echo "error"; 
   } 
?>
 

noerrorsfound

New Member
Messages
1,736
Reaction score
1
Points
0
Why would you want to do this? What about the people using other browsers, such as Mozilla Suite, SeaMonkey, or Safari? Why do you want to stop them from viewing your site?
 
Top