Hello,

don't know much about PHP. trying to convert the following into php from perl

if ($ENV{HTTP_USER_AGENT} =~ /compatible; MSIE [0-9]/ && $ENV{HTTP_USER_AGENT}!~ /Opera/) { ... }

Opera can be set to identify itself as IE, However the user agent for Opera
contains both "MSIE" and "Opera"when you do this. The above script says in perl if IE and not Opera then i can do what i want.

i started with this for a php script

<?php
$user_agent = $_SERVER["HTTP_USER_AGENT"];
$pos = strpos($user_agent, "MSIE");
if($pos) header("Location: http://www.domainname.com");
?>

how can i add to the $pos is "MSIE" and not "Opera" to do the if? I specifically want to detect and direct IE users to a page and Opera users to another page.

    pretty simple...

    if (strpos($user_agent,"MSIE"))
    {  if (strpos($user_agent,"Opera"))
        {
            //this is opera + MSIE
         }
    else
    {
        //this is just IE
    }
    

      So would this be the final?

      <?php
      if (strpos($user_agent,"MSIE"))
      { if (strpos($user_agent,"Opera"))
      {
      header("Location: http://domainname1.com"); //this is opera
      }
      else
      {
      header("Location: http://domainname2.com"); //this is IE
      }
      ?>

      I apologize for my ignornance, i'm ok with general html/xml but i just don't know anything about php other then what i find by google searches and moding it.

        This is the final code, i created an msie.inc add added the following code to it referencing it from the index.php. It allows users of Opera to continue to the page whether they are set to identify as Opera or as IE and actual IE users are directed to a different page.

        <?php
        if ((stristr(getenv('HTTP_USER_AGENT') , 'MSIE')) && (!stristr(getenv('HTTP_USER_AGENT') , 'opera')))
        {
        header("Location: http://domainname.com");
        }
        ?>

          Write a Reply...