jamesjmann Posted February 22, 2011 Share Posted February 22, 2011 If a user is using internet explorer, display error "You are not using a browser that is supported. Please reload in Google Chrome or Mozilla Firefox to access content", otherwise display page. Not sure if this is possible with an if else statement, or even php for that matter. Does anyone know what I'm talking about, and if so, any suggestions? Quote Link to comment https://forums.phpfreaks.com/topic/228455-not-sure-how-to-explain-this/ Share on other sites More sharing options...
Zurev Posted February 22, 2011 Share Posted February 22, 2011 If a user is using internet explorer, display error "You are not using a browser that is supported. Please reload in Google Chrome or Mozilla Firefox to access content", otherwise display page. Not sure if this is possible with an if else statement, or even php for that matter. Does anyone know what I'm talking about, and if so, any suggestions? I do: $using_ie = (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== FALSE); if ($using_ie) { die("We hate your browser (Internet Explorer), and therefore you don't deserve to use our site.<br /><a href='http://www.google.com/chrome/intl/en/landing_chrome.html?hl=en'>Get Chrome</a>"); } I think it has some flaws though since some browsers have MSIE in the tag, older versions of Opera I think.. Overall I advise against this anyway, I just do it in spite of IE for the time being till I fix my problems with it. If it's styling that's the issue, look into conditional stylesheets. (Meaning, use one stylesheet for IE, and another for other browsers). Quote Link to comment https://forums.phpfreaks.com/topic/228455-not-sure-how-to-explain-this/#findComment-1178011 Share on other sites More sharing options...
jamesjmann Posted February 22, 2011 Author Share Posted February 22, 2011 If a user is using internet explorer, display error "You are not using a browser that is supported. Please reload in Google Chrome or Mozilla Firefox to access content", otherwise display page. Not sure if this is possible with an if else statement, or even php for that matter. Does anyone know what I'm talking about, and if so, any suggestions? I do: $using_ie = (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== FALSE); if ($using_ie) { die("We hate your browser (Internet Explorer), and therefore you don't deserve to use our site.<br /><a href='http://www.google.com/chrome/intl/en/landing_chrome.html?hl=en'>Get Chrome</a>"); } I think it has some flaws though since some browsers have MSIE in the tag, older versions of Opera I think.. Overall I advise against this anyway, I just do it in spite of IE for the time being till I fix my problems with it. If it's styling that's the issue, look into conditional stylesheets. (Meaning, use one stylesheet for IE, and another for other browsers). See, I tried that because I'm using the new CSS3 animations and box shadows, etc. and it's too complicated for me to add multibrowser support for each one, so I decided to just go with this method. I have a couple questions about your code... 1. Do I wrap the entire document (including the !doctype tag) inside the <php> tags? 2. What do you mean some browsers have MSIE in the tag? Quote Link to comment https://forums.phpfreaks.com/topic/228455-not-sure-how-to-explain-this/#findComment-1178020 Share on other sites More sharing options...
denno020 Posted February 22, 2011 Share Posted February 22, 2011 as Zurev suggested, you probably shouldn't completely remove IE from the access list.. You really need to set up a style sheet for IE. Obviously without the coolness of CSS3. You can just display a message to the user that you know they're using IE and they won't get the full experience of your website unless they switch to a (better) browser like Chrome or Firefox.. Denno Quote Link to comment https://forums.phpfreaks.com/topic/228455-not-sure-how-to-explain-this/#findComment-1178035 Share on other sites More sharing options...
Zurev Posted February 22, 2011 Share Posted February 22, 2011 If you so must... <?php $using_ie = (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== FALSE); if ($using_ie) { die("We hate your browser (Internet Explorer), and therefore you don't deserve to use our site.<br /><a href='http://www.google.com/chrome/intl/en/landing_chrome.html?hl=en'>Get Chrome</a>"); } // any other php code you have could go here... ?> doctype html body etc Quote Link to comment https://forums.phpfreaks.com/topic/228455-not-sure-how-to-explain-this/#findComment-1178277 Share on other sites More sharing options...
jamesjmann Posted February 23, 2011 Author Share Posted February 23, 2011 If you so must... <?php $using_ie = (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== FALSE); if ($using_ie) { die("We hate your browser (Internet Explorer), and therefore you don't deserve to use our site.<br /><a href='http://www.google.com/chrome/intl/en/landing_chrome.html?hl=en'>Get Chrome</a>"); } // any other php code you have could go here... ?> doctype html body etc I put that code right after the <body> tag, because it was conflicting with other php code I have before the <!doctype> tag. I have another question, though. What are the other browser names? For example, $using_ie = (strpos($_SERVER['HTTP_USER_AGENT'], 'Firefox') !== FALSE); for Mozilla Firefox. Is there a list online somewhere with all of the browser's names on it, specific to this kind of code? Quote Link to comment https://forums.phpfreaks.com/topic/228455-not-sure-how-to-explain-this/#findComment-1178796 Share on other sites More sharing options...
BlueSkyIS Posted February 23, 2011 Share Posted February 23, 2011 http://www.google.com/search?client=safari&rls=en&q=browser+user+agents&ie=UTF-8&oe=UTF-8 Quote Link to comment https://forums.phpfreaks.com/topic/228455-not-sure-how-to-explain-this/#findComment-1178898 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.