How To Remind IE6 Users Who Visit Your Site To Upgrade

Well, we’ve heard time and time again that IE6 needs to go away and stay away. Heck, even Microsoft wants it gone for good.

If you know the basics of PHP, below are code examples you can use to remind IE6 users to upgrade on your own web site, should you have one.

Requirements: A Linux or UNIX based web server running Apache and PHP. The vast majority of web host providers are set up like this. No database is required as it’s just code that reads browser user agent data.

Use one of the code examples below and paste it at the top of the code for your home page.

Friendly version

<?php
if (preg_match("/MSIE 6.0/i", $_SERVER['HTTP_USER_AGENT'])) {
    echo ("
    <span style='text-align: center;
                 width: 100%;
                 background-color: #cfc;
                 color: #000;
                 border: 1px solid #000;
                 padding: 1em;
                 font-family: sans-serif;
                 font-size: 1em;
                 '>
    Hello! You appear to be using a
    really old version of Internet
    Explorer. You should upgrade!
    </span>
    ");
}

When an IE6 user loads your site, they will see a green box at top with the message like this:

image

The "Hello, world!" part is where the rest of your web page would be.

Not-So Friendly version

if (preg_match("/MSIE 6.0/i", $_SERVER['HTTP_USER_AGENT'])) {
    echo ("
    <span style='text-align: justify;
                 width: 100%;
                 background-color: #f00;
                 color: #ff0;
                 border: 1px solid #000;
                 padding: 1em;
                 font-family: impact;
                 font-size: 4em;
                 '>
    YOU ARE USING A REALLY OLD, AWFUL BROWSER THAT IS
    RESPONSIBLE FOR SOGGY RICE KRISPIES, COMMUNISM AND
    THE GOUT. THIS BROWSER IS IE6. IT IS BAD, THEREFORE
    YOU ARE BAD. UPGRADE OR DIE, FOOL.
    </span>
    ");
}

This will result in the IE6 user seeing this:

image

Just imagine what that would look like full-size (eek!)

Some webmasters just hate IE with a passion and want their users to know that if they use IE6 voluntarily or not on their site, they’ll be sorry for it. :)

Free eBook!

Like what you read?

If so, please join over 28,000 people who receive our exclusive weekly newsletter and computer tips, and get FREE COPIES of 5 eBooks we created, as our gift to you for subscribing. Just enter your name and email below:

Post A Comment Using Facebook

Discuss This Article (Without Facebook)

2 comments

  1. Anonymous /

    Sorry, but I think it’s bad idea to use php and regex (which is slow).
    We can use only HTML:
    http://pastebin.com/zSMjgUV3

    If you want to use php, you can use faster function, such like:
    http://www.php.net/manual/en/function.strstr.php

  2. Anonymous /

    Sorry, but I think it’s bad idea to use php and regex (which is slow).
    We can use only HTML:
    http://pastebin.com/zSMjgUV3

    If you want to use php, you can use faster function, such like:
    http://www.php.net/manual/en/function.strstr.php

Leave a Reply

PCMech Insider Cover Images - Subscribe To Get Your Copies!
Learn More
Every week, hundreds of tech enthusiasts, computer owners
and geeks read The Insider, the digital magazine of PCMech.

What’s Your Preference?

Daily Alerts

Each day we send out a quick email to thousands of PCMECH readers to notify them of new posts. This email is just a short, plain email with titles and links to our latest posts. You can unsubscribe from this service at any time.

You can subscribe to it by leaving your email address in the following field and confirming your subscription when you get an email asking you to do so.

Enter your email address for
Daily Updates:

Weekly Newsletter

Running for over 6 years, the PCMECH weekly newsletter helps you keep tabs on the world of tech. Each issue includes news bits, an article, an exclusive rant as well as a download of the week. This newsletter is subscribed to by over 28,000 readers (many who also subscribe to the other option) - come join the community!

To subscribe to this weekly newsletter simply add your email address to the following field and then follow the confirmation prompts. You will be able to unsubscribe at any time.

Enter your email address for
Free Weekly Newsletter: