PHP Style Switcher - Browser Problems

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Amanda H.

    #1

    PHP Style Switcher - Browser Problems

    I posted about this a few days ago, and I got a few suggestions that
    fixed part of my problem.

    I am using a PHP script to switch external style sheets when the viewer
    clicks on the style link. Search "Amanda H." in this group and you can
    view my last post to see the original PHP and html junk. This below is
    the updated link rel and the meta tags.

    Before, it wouldn't refresh or change in Opera, Firefox, or IE6/Win &
    IE5/Mac. The bits added on to the link rel and adding the meta tags
    worked for Firefox and Opera.

    In IE6/Win, the style sheet loads, but a manual refresh makes it
    actually load. In IE5/Mac, the style sheets won't switch at all. I
    don't know PHP very well, so I don't know what the problem could be.
    Any help would be greatly appreciated. Here's the script and code:
    -------------------------

    <?
    header('Content-Type: text/css');
    // CONFIGURATION
    // If you want to specify a default CSS file for users who can't handle

    // cookies, replace styles.css with the filename below:

    $basicsheet = "basic.css" ;

    // CHECK IF NEW STYLESHEET IS BEING LOADED
    if(isset($_GET['sheet']) OR isset($_POST['sheet'])) {

    // CHECK IF FILE IS SPECIFIED IN URL
    if(isset($_GET['sheet'])) { $newsheet = $_GET['sheet']; }

    // CHECK IF FILE IS SPECIFIED IN FORM DATA
    if(isset($_POST['sheet'])) { $newsheet = $_POST['sheet']; }

    // MAKE THE USER REMEMBER WHICH STYLESHEET IS LOADED
    setcookie("my_s tylesheet", "$newsheet.css" , 0, "/");

    // SEND THE USER BACK
    $ref = $_SERVER['HTTP_REFERER'];
    header("Locatio n: $ref");

    } else {

    // NORMAL STYLESHEET REQUEST
    $mysheet = $_COOKIE['my_stylesheet'];
    if($mysheet == "") { $mysheet = $basicsheet; }
    include "$mysheet";
    }

    ?>

    -----------------------------------------
    ---end of PHP script. Then the new link header & meta tags for the
    HTML file:

    <link rel="stylesheet " type="text/css"
    href="http://www.amandahenso n.com/styleswitcher.p hp?<?php echo time();
    ?>" />

    and


    <meta http-equiv="cache-control" content="no-cache" />
    <meta http-equiv="pragma" content="no-cache" />

    -------------------------------------
    ---end. It works in most browsers, but it still has those problems
    with the browsers mentioned above. Thanks ahead of time.

    Amanda H.

  • google@impliedbydesign.com

    #2
    Re: PHP Style Switcher - Browser Problems

    Hello Amanda,

    I don't think there's a PHP problem. My guess is that you're running
    into an issue with the COOKIE variable. Try using a session variable
    instead and see if that works.

    Chris S.
    Implied By Design

    Free Web Development Programs and Scripts


    Comment

    Working...