+ Reply to Thread
Results 1 to 9 of 9

Thread: Need some php help

  1. #1
    dharmil's Avatar
    dharmil is offline x10 Elder dharmil is an unknown quantity at this point
    Join Date
    Sep 2005
    Location
    Avenel New Jersey
    Posts
    828

    Need some php help

    i have made a site but only want users using firefox, ie and opera to be able to view it if they dont have it then they get redirected to another page
    can any body helps me out with this

    i have some thing but it doesnt work well
    PHP Code:
    <?
    if (eregi("firefox",$_SERVER['HTTP_USER_AGENT'])){
    echo 
    "firefox";
    }
    if (
    eregi("ie",$_SERVER['HTTP_USER_AGENT'])){
    echo 
    "ie";
    }
    if (
    eregi("opera",$_SERVER['HTTP_USER_AGENT'])){
    echo 
    "opera";
    }
    else {
    echo 
    "error";
    }
    ?>
    but when i use fire fox it still says firefox error
    but its not supost to say error
    Last edited by dharmil; 07-20-2006 at 01:10 PM.

  2. #2
    Chris Z's Avatar
    Chris Z is offline x10 Spammer Chris Z is an unknown quantity at this point
    Join Date
    Sep 2005
    Location
    Alabama, USA
    Posts
    2,802

    Re: Need some php help

    try just using "HTTP_USER_AGENT", take the "$_SERVER" part off see if that works
    Last edited by Chris Z; 07-20-2006 at 05:22 PM.
    -Chris Z
    Retired Account Manager


  3. #3
    Bryon is offline Administrator Bryon has disabled reputation
    Join Date
    Apr 2005
    Location
    Northfield, NH
    Posts
    7,608

    Re: Need some php help

    PHP Code:

    <?php
       $userAgent 
    'Filler'$_SERVER['HTTP_USER_AGENT'];
       if (
    stripos($userAgent'firefox')){
          echo 
    "firefox";
       }
       elseif (
    stripos($userAgent'ie')){
          echo 
    "ie";
       }
       elseif (
    stripos($userAgent'opera')){
          echo 
    "opera";
       }
       else {
          echo 
    "error";
       }
    ?>

  4. #4
    dharmil's Avatar
    dharmil is offline x10 Elder dharmil is an unknown quantity at this point
    Join Date
    Sep 2005
    Location
    Avenel New Jersey
    Posts
    828

    Re: Need some php help

    thanks it works perfect
    Last edited by dharmil; 07-20-2006 at 08:49 PM.

  5. #5
    nightscream is offline x10 Lieutenant nightscream is an unknown quantity at this point
    Join Date
    Feb 2006
    Location
    Hallaar, Belgium
    Posts
    474

    Re: Need some php help

    isn't case faster then if
    ------------------------------------------------------------------------------------------
    If you have any troubles with a website or a script, just send me a pm.

    I also code websites in xHTML/css, can code javascript and php too if needed

  6. #6
    LiaoHua is offline x10Hosting Member LiaoHua is an unknown quantity at this point
    Join Date
    Apr 2006
    Posts
    3

    Re: Need some php help

    As I see:

    $_SERVER['HTTP_USER_AGENT'] = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; POTU(1.13))"

    And you need to pickup "MSIE".

  7. #7
    [XiRE] is offline x10Hosting Member [XiRE] is an unknown quantity at this point
    Join Date
    Jul 2006
    Location
    Detroit Michigan
    Posts
    44

    Re: Need some php help

    Quote Originally Posted by LiaoHua
    As I see:

    $_SERVER['HTTP_USER_AGENT'] = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; POTU(1.13))"

    And you need to pickup "MSIE".
    PHP Code:
    <?php 
       $userAgent 
    'Filler'$_SERVER['HTTP_USER_AGENT']; 
       if (
    stripos($userAgent'FF')){ 
          echo 
    "firefox"
       } 
       elseif (
    stripos($userAgent'MSIE')){ 
          echo 
    "ie"
       } 
       elseif (
    stripos($userAgent'opera')){ 
          echo 
    "opera"
       } 
       else { 
          echo 
    "error"
       } 
    ?>

  8. #8
    noerrorsfound is offline x10 Elder noerrorsfound is an unknown quantity at this point
    Join Date
    Mar 2006
    Posts
    868

    Re: Need some php help

    Why would you want to do this? What about the people using other browsers, such as Mozilla Suite, SeaMonkey, or Safari? Why do you want to stop them from viewing your site?
    EOF

  9. #9
    dharmil's Avatar
    dharmil is offline x10 Elder dharmil is an unknown quantity at this point
    Join Date
    Sep 2005
    Location
    Avenel New Jersey
    Posts
    828

    Re: Need some php help

    because i have diffrent skins and some brows dont support the new skin
    so for those browser it will display the old skin example

    go to www.dharmil.info/news.php on fire fox or opera or netscape

    then go to to www.dharmil.info/news.php on Internet explorer and the layout will be diffrent

+ Reply to Thread

Similar Threads

  1. [PHP] MySQL and PHP
    By Bryon in forum Tutorials
    Replies: 43
    Last Post: 03-24-2011, 07:27 AM
  2. [PHP] Variables in PHP
    By Bryon in forum Tutorials
    Replies: 15
    Last Post: 01-29-2009, 09:46 AM
  3. tons of PHP Resources
    By Chris S in forum Scripts & 3rd Party Apps
    Replies: 10
    Last Post: 01-16-2009, 10:07 AM
  4. [PHP] PHP For Starters
    By Complex in forum Tutorials
    Replies: 24
    Last Post: 06-14-2008, 11:40 PM
  5. Unstand PHP?
    By o0slowpaul0o in forum Tutorials
    Replies: 8
    Last Post: 01-07-2008, 09:16 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers