Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    Regular Coder levani's Avatar
    Join Date
    Mar 2009
    Location
    Georgia
    Posts
    183
    Thanks
    29
    Thanked 1 Time in 1 Post

    If internet explorer 8

    How can I get information whether an user uses internet explorer 8 or not? I use this code for IE 6, but it doesn't seem to work on IE 8.

    PHP Code:
    <?php
    //if the browser is Microsoft IE
    if (strstr($_SERVER['HTTP_USER_AGENT'], "MSIE")) {
    if (
    ereg('MSIE 6',$_SERVER['HTTP_USER_AGENT']))
       include (
    TEMPLATEPATH '/form_ie.php');
    } else {
        include (
    TEMPLATEPATH '/form_other.php');
    }
    ?>
    What I want to do is to execute different code if user comes from IE6 or older and different for all other browsers (including IE 7 and 8).

    Any ideas?

  • #2
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,471
    Thanks
    8
    Thanked 1,085 Times in 1,076 Posts
    This might help ...

    http://www.php-scripts.com/20050912/12/

    I'm guessing you can alter [0-9] to [0-6] or [7-9] to pick out the version you want.

  • #3
    GŁtkodierer
    Join Date
    Apr 2009
    Posts
    2,127
    Thanks
    1
    Thanked 426 Times in 424 Posts
    You did change that '6' to an '8' there, right?

    Anyway, the surefire way is to use conditional comments in your html, but that means that you will need at least two http-requests until you get that browser information into your server side script.

  • #4
    Regular Coder levani's Avatar
    Join Date
    Mar 2009
    Location
    Georgia
    Posts
    183
    Thanks
    29
    Thanked 1 Time in 1 Post
    My code above works as it must be on every browser, but IE8. On IE8 it doesn't include neither "form_ie.php" nor "form_other.php". Why?

    I want it to include form_other.php if the browser is IE8...

  • #5
    GŁtkodierer
    Join Date
    Apr 2009
    Posts
    2,127
    Thanks
    1
    Thanked 426 Times in 424 Posts
    Ok, I see the problem. What you are doing is:

    Are you an IE? If yes, are you IE6? Then you get form_ie.
    Oh, you're not an IE? Then you get form_other.

    No IE, except 6, will ever get anything included.

    If you want only IE6 to get form_ie and every other browser form_other, do it like this:

    PHP Code:
    if (ereg('MSIE 6',$_SERVER['HTTP_USER_AGENT'])){
       include (
    TEMPLATEPATH '/form_ie.php');
    } else {
        include (
    TEMPLATEPATH '/form_other.php');



  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •