Jump to content

Archived

This topic is now archived and is closed to further replies.

cmgmyr

Session and XHTML validation error

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

Share this post


Link to post
Share on other sites
Easy solution - adjust the arg separator - http://www.w3.org/QA/2005/04/php-session

Share this post


Link to post
Share on other sites
I just decided to change it to cookie based instead...it works great!

Share this post


Link to post
Share on other sites

×

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.