Disable Internet Explorer in PHP

10 posts Page 1 of 1
Contributors
User avatar
Livengood
Serious Programmer
Serious Programmer
Posts: 444
Joined: Tue Feb 16, 2010 6:24 am

Disable Internet Explorer in PHP
Livengood
I am going to share how to disable your website on internet explorer web browsers. What your going to do is get the webbrowser the user is using.
Code: Select all
$_SERVER['HTTP_USER_AGENT']
This will get the name of the webbrowser + everything else. Next, adding the if statement plus the "strpos."
Code: Select all
<?php
   if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE')) {
		
   }
?>
Finally the full code:
Code: Select all
<?php
   if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE')) {
      echo "This site does not support Microsoft Internet Explorer";
   } else { 
      echo "Your not using Microsoft Internet Explorer";
   }
?>
Thanks,
Austin Livengood
Image
User avatar
Dummy1912
VIP - Donator
VIP - Donator
Posts: 1969
Joined: Sat Aug 21, 2010 2:17 pm

so does this mean you can't access a webite with internet explorer?

sound great because mine website don't support internet explorer
so im happy with this code :)

thanks :)
visit us on:


http://www.softpedia.com/get/System/Lau ... -Run.shtml
Check it out ! http://www.softpedia.com/publisher/I-A- ... 90017.html
Check it out ! http://www.softpedia.com/get/Desktop-En ... lock.shtml
User avatar
Dummy1912
VIP - Donator
VIP - Donator
Posts: 1969
Joined: Sat Aug 21, 2010 2:17 pm

is there a way so it can be showed
that only IE9 been support?

can you helpme please blusho;
visit us on:


http://www.softpedia.com/get/System/Lau ... -Run.shtml
Check it out ! http://www.softpedia.com/publisher/I-A- ... 90017.html
Check it out ! http://www.softpedia.com/get/Desktop-En ... lock.shtml
User avatar
Codex
Coding God
Coding God
Posts: 2028
Joined: Wed Mar 31, 2010 5:50 pm

Re: Disable Internet Explorer in PHP
Codex
The code is wrong, you should use die(" "); instead of echo " ";
Code: Select all
<?php
   if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE')) {
      die("This site does not support Microsoft Internet Explorer");
   } else { 
      echo "Your not using Microsoft Internet Explorer";
   }
?>
But if you want to accept IE only, they you should do this:
Code: Select all
<?php
   if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE')) {
      echo "This site does not support Microsoft Internet Explorer";
   } else { 
      die("Your not using Microsoft Internet Explorer");
   }
?>
Or if you just want to disable IE 6/7/8/9, place the number after MSIE
Code: Select all
<?php
   if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE 6')) {
      die("This site does not support Microsoft Internet Explorer 6");
   } else { 
      echo "Your not using Microsoft Internet Explorer";
   }
?>
For more user-agent info, visit this
Last edited by Codex on Mon Nov 07, 2011 9:38 pm, edited 1 time in total.
We shall let the revolution begin.. the revolution for freedom, freedom against censorship. We shall fight in the fields and in the streets, we shall fight in the hills; we shall never surrender
User avatar
Scottie1972
Codenstuff Elite
Codenstuff Elite
Posts: 953
Joined: Thu Jan 14, 2010 5:48 am

i love this code.
do to that IE does not support "Radius" or "Shadow" effects for CSS.
Microsoft should stop creating new stuff and work on making the old stuff work. Better!
Image
User avatar
CodenStuff
Site Admin
Site Admin
Posts: 4389
Joined: Tue Aug 04, 2009 1:47 am

The problem you will face by blocking users of a certain browser type like IE from viewing your site is that if those people are dedicated IE users they wont go through the hassle of having to download and install another browser just to be able to view your site meaning you will lose them as potential users, members, customers and IE is still used by 40-50% of people and IE6 still has is worshippers although I have no idea why :? lol.
Welcome to CodenStuff.com Learn Code, Love Code. Thank you for being a member of the community.
User avatar
Dummy1912
VIP - Donator
VIP - Donator
Posts: 1969
Joined: Sat Aug 21, 2010 2:17 pm

well the problem is with IE it don't accept PHP code cood :(
i have tested it 100 times with danny and still not working 100%

we don't know why but it was we even downloaded version IE9
and still the same problem.

thats the sad part :(
visit us on:


http://www.softpedia.com/get/System/Lau ... -Run.shtml
Check it out ! http://www.softpedia.com/publisher/I-A- ... 90017.html
Check it out ! http://www.softpedia.com/get/Desktop-En ... lock.shtml
User avatar
Danny
VIP - Donator
VIP - Donator
Posts: 621
Joined: Sat Oct 30, 2010 8:21 pm

Re: Disable Internet Explorer in PHP
Danny
Thats true, we've worked on it whole day to get it right, I made a new website for dummy in html 5 and without php it shows perfectly but with it is crap cryer; cryer;
User avatar
Scottie1972
Codenstuff Elite
Codenstuff Elite
Posts: 953
Joined: Thu Jan 14, 2010 5:48 am

idk what you guys are doing.
i have worked with PHP for years only using IE until Chrome came out.
and the only problems i ever had with PHP and IE was coding errors.
Developer error. In other words. I was doing something wrong.

Just just do like IE cause it can not parse CSS like the other browsers can.

Chrome Example:
Image

IE Example:
Image

If this is the case. I dont want anyone using IE to visit my site.
IE makes things look to ugly. Some issues I can work with.
Internet Explorer and the border-radius Properties

While the W3C has specified the border-radius properties in its latest CSS3 working draft, Microsoft has not implemented the border-radius properties in Internet Explorer 8.

Microsoft is committed to providing a browser that accurately supports Web standards. In Internet Explorer 8, we shipped several features from HTML5 and CSS3. Our primary goal was implementing CSS 2.1 (a specification that has reached final candidate stage) completely and correctly before moving on to specifications that are still in development and may change.
Reference Link from msdn.microsoft.com


It isn't a question of who can or who can not access the site.
To me it is a question of a Standard. If IE can not keep up with the rest of the world. Then the browser should be removed from publication.
Image
User avatar
Livengood
Serious Programmer
Serious Programmer
Posts: 444
Joined: Tue Feb 16, 2010 6:24 am

I like that this code has become a discussion. Glad you all like this code xD. I will share some more. php<3
Image
10 posts Page 1 of 1
Return to “Help & Support”