Wildhalf Posted May 22, 2007 Share Posted May 22, 2007 Hi all, This is an easy one for some of you but i haven't seen a way to do it... I want to distingush between browsers Users are visiting your page with. If there using anything other than IE i want to tell them that the page is best view in IE and try get them to open it in IE. Anyone have any ideas??? Quote Link to comment https://forums.phpfreaks.com/topic/52554-solved-distingush-between-browsers-users-are-visiting-your-page-with/ Share on other sites More sharing options...
B34ST Posted May 22, 2007 Share Posted May 22, 2007 you can see what browser a user is using like this: echo $_SERVER['HTTP_USER_AGENT'] . "\n\n"; Im not sure if there is function to distinguish between browsers but ince you have got the data you could always use preg_match() if it finds a match then output your page if not display the message. Quote Link to comment https://forums.phpfreaks.com/topic/52554-solved-distingush-between-browsers-users-are-visiting-your-page-with/#findComment-259328 Share on other sites More sharing options...
QWERTYtech Posted May 22, 2007 Share Posted May 22, 2007 Just found this on the web. if (!empty($_SERVER['HTTP_USER_AGENT'])) { $HTTP_USER_AGENT = $_SERVER['HTTP_USER_AGENT']; } else if (!empty($HTTP_SERVER_VARS['HTTP_USER_AGENT'])) { $HTTP_USER_AGENT = $HTTP_SERVER_VARS['HTTP_USER_AGENT']; } else if (!isset($HTTP_USER_AGENT)) { $HTTP_USER_AGENT = ''; } if (ereg('Opera(/| )([0-9].[0-9]{1,2})', $HTTP_USER_AGENT, $log_version)) { $browser_version = $log_version[2]; $browser_agent = 'opera'; } else if (ereg('MSIE ([0-9].[0-9]{1,2})', $HTTP_USER_AGENT, $log_version)) { $browser_version = $log_version[1]; $browser_agent = 'ie'; } else if (ereg('OmniWeb/([0-9].[0-9]{1,2})', $HTTP_USER_AGENT, $log_version)) { $browser_version = $log_version[1]; $browser_agent = 'omniweb'; } else if (ereg('Netscape([0-9]{1})', $HTTP_USER_AGENT, $log_version)) { $browser_version = $log_version[1]; $browser_agent = 'netscape'; } else if (ereg('Mozilla/([0-9].[0-9]{1,2})', $HTTP_USER_AGENT, $log_version)) { $browser_version = $log_version[1]; $browser_agent = 'mozilla'; } else if (ereg('Konqueror/([0-9].[0-9]{1,2})', $HTTP_USER_AGENT, $log_version)) { $browser_version = $log_version[1]; $browser_agent = 'konqueror'; } else { $browser_version = 0; $browser_agent = 'other'; } echo '<HR WIDTH="100%" COLOR="black"/>'; print '<B>Browser Type:</B> ' . $browser_agent; echo '<BR />'; print '<B>Browser Version #:</B> ' . $browser_version; echo '<HR WIDTH="100%" COLOR="black"/><PRE><B>Full Details:</B> '; print_r( $HTTP_USER_AGENT ); echo '</PRE><HR WIDTH="100%" COLOR="black"/>'; Give all the credit to this site.....Site Quote Link to comment https://forums.phpfreaks.com/topic/52554-solved-distingush-between-browsers-users-are-visiting-your-page-with/#findComment-259346 Share on other sites More sharing options...
Wildhalf Posted May 22, 2007 Author Share Posted May 22, 2007 Thank you both i will check it out later should be able to figure it out from there Quote Link to comment https://forums.phpfreaks.com/topic/52554-solved-distingush-between-browsers-users-are-visiting-your-page-with/#findComment-259348 Share on other sites More sharing options...
Wuhtzu Posted May 22, 2007 Share Posted May 22, 2007 Remember that things like: $_SERVER['HTTP_REFERER'] $_SERVER['HTTP_USER_AGENT'] are set by the user agent it self (the browser) and it can therefore be manipulated. I guess some browsers even offer the ability to do that very easy. But of course if it's for the viewers own good you can give a heck about someone trying to cheat it / bypass it - since it will only do them no good Quote Link to comment https://forums.phpfreaks.com/topic/52554-solved-distingush-between-browsers-users-are-visiting-your-page-with/#findComment-259352 Share on other sites More sharing options...
Wildhalf Posted May 23, 2007 Author Share Posted May 23, 2007 Works perfectly... Thanks again Just found this on the web. if (!empty($_SERVER['HTTP_USER_AGENT'])) { $HTTP_USER_AGENT = $_SERVER['HTTP_USER_AGENT']; } else if (!empty($HTTP_SERVER_VARS['HTTP_USER_AGENT'])) { $HTTP_USER_AGENT = $HTTP_SERVER_VARS['HTTP_USER_AGENT']; } else if (!isset($HTTP_USER_AGENT)) { $HTTP_USER_AGENT = ''; } if (ereg('Opera(/| )([0-9].[0-9]{1,2})', $HTTP_USER_AGENT, $log_version)) { $browser_version = $log_version[2]; $browser_agent = 'opera'; } else if (ereg('MSIE ([0-9].[0-9]{1,2})', $HTTP_USER_AGENT, $log_version)) { $browser_version = $log_version[1]; $browser_agent = 'ie'; } else if (ereg('OmniWeb/([0-9].[0-9]{1,2})', $HTTP_USER_AGENT, $log_version)) { $browser_version = $log_version[1]; $browser_agent = 'omniweb'; } else if (ereg('Netscape([0-9]{1})', $HTTP_USER_AGENT, $log_version)) { $browser_version = $log_version[1]; $browser_agent = 'netscape'; } else if (ereg('Mozilla/([0-9].[0-9]{1,2})', $HTTP_USER_AGENT, $log_version)) { $browser_version = $log_version[1]; $browser_agent = 'mozilla'; } else if (ereg('Konqueror/([0-9].[0-9]{1,2})', $HTTP_USER_AGENT, $log_version)) { $browser_version = $log_version[1]; $browser_agent = 'konqueror'; } else { $browser_version = 0; $browser_agent = 'other'; } echo '<HR WIDTH="100%" COLOR="black"/>'; print '<B>Browser Type:</B> ' . $browser_agent; echo '<BR />'; print '<B>Browser Version #:</B> ' . $browser_version; echo '<HR WIDTH="100%" COLOR="black"/><PRE><B>Full Details:</B> '; print_r( $HTTP_USER_AGENT ); echo '</PRE><HR WIDTH="100%" COLOR="black"/>'; Give all the credit to this site.....Site Quote Link to comment https://forums.phpfreaks.com/topic/52554-solved-distingush-between-browsers-users-are-visiting-your-page-with/#findComment-259929 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.