Jump to content

Session and XHTML validation error


cmgmyr

Recommended Posts

I just made a style switcher for my site and now the page doesn't validate

The site is www.chrisgmyr.com go to the validation results.

here is style-switcher.php
[code=php:0]<?php
session_start();
$all_css = array();

$all_css['default']['file'] = "css/style.css"; // default
$all_css['red']['file'] = "css/red.css";
$all_css['blue']['file'] = "css/blue.css";
$all_css['green']['file'] = "css/green.css";

$all_css['default']['label'] = "Default"; // default
$all_css['red']['label'] = "Red";
$all_css['blue']['label'] = "Blue";
$all_css['green']['label'] = "Green";

$default_value = "default"; // set the default value here

if (isset($_GET['change_css']) && $_GET['change_css'] != "") {
    $_SESSION['css'] = $_GET['change_css'];
} else {
    $_SESSION['css'] = (!isset($_SESSION['css'])) ? $default_value : $_SESSION['css'];
}
switch ($_SESSION['css']) {
    case "red":
    $css_file = "css/red.css";
    break;
    case "blue":
    $css_file = "css/blue.css";
    break;
case "green":
    $css_file = "css/green.css";
    break;
    default:
    $css_file = "css/style.css";
}
function style_switcher() {
    global $all_css,$PHP_SELF;
$self = $PHP_SELF;
$stripslash = explode("/", $self);
$self = $stripslash[1];

    $style_links = "";
    foreach ($all_css as $key => $val) {
        if ($_SESSION['css'] != $key) {
            $style_links .= "<a href=\"$self?change_css=$key\">";
            $style_links .= "".$val['label']."</a>";
        } else {
            $style_links .= "<span class=\"current\">".$val['label']."</span>";
        }
    }
    return $style_links;
}
?>[/code]

any ideas on what I can do to fix it?

Thanks,
-Chris
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.