Jump to content

phpasaurusREX

New Members
  • Posts

    9
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

phpasaurusREX's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. [!--quoteo(post=377932:date=May 28 2006, 08:07 PM:name=poirot)--][div class=\'quotetop\']QUOTE(poirot @ May 28 2006, 08:07 PM) [snapback]377932[/snapback][/div][div class=\'quotemain\'][!--quotec--]I think it's because you are using aleternative style sheets to set the font/color. So probably IE keeps using the main CSS.[/quote]You are right on the money. I changed rel="alternate stylesheet" to rel="stylesheet" and now it works perfectly in IE and Firefox. Thanks!
  2. Here is a link to the demo: [a href=\"http://designx.biz/index.php\" target=\"_blank\"]http://designx.biz/index.php[/a] If you open the above link in Firefox, you can change the font and background color. If you open the above link in Internet Explorer, you cannot change the font and background color. [b]This is driving me nuts, can anyone help me?[/b] Here is a link to a ZIP file containing all the file: [a href=\"http://designx.biz/styleswitcher.zip\" target=\"_blank\"]http://designx.biz/styleswitcher.zip[/a] Here is the code for index.php [code] <?php include_once('switcher_background.php'); include_once('switcher_font.php'); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml">     <head>         <title>Style Switcher</title>         <meta http-equiv="content-type" content="text/html; charset=utf-8" />         <link rel="stylesheet" type="text/css" href="css/screen.css">         <?php include_background(); ?>         <?php include_font(); ?>     </head>     <body>         <h1>Style Switcher</h1>         <?php font_style_form_open(); ?>                 <?php font_style_form_list(5); ?>                 <?php font_style_form_button('Switch Font'); ?>         <?php font_style_form_close(); ?>         <?php background_style_form_open(); ?>                 <?php background_style_form_list(5); ?>                 <?php background_style_form_button('Switch Background'); ?>         <?php background_style_form_close(); ?>     </body> </html> [/code] Here is the code for switcher_background.php [code] <?php $root = $_SERVER['DOCUMENT_ROOT'] . '/'; $background_style_directory = 'css/background/'; $extension = '.css'; $special_character = '_'; function include_background() {     global $host, $background_style_directory, $background_style_current, $linebreak;          echo '<link rel="alternative stylesheet" type="text/css" href="' . $background_style_directory . $background_style_current . '" title="User Defined Style" />' . $linebreak; } function background_cookie_read() {     global $background_styles;          if (isset($_COOKIE['switcher_background']))     {         return $_COOKIE['switcher_background'];     }     else if (count($background_styles) > 0)     {         return $background_styles[0];     }     else     {         return null;     } } function background_cookie_write($style) {     global $host;          if ($host == 'localhost')     {         setcookie('switcher_background', $style, time() + 31536000, '/');     }     else     {         setcookie('switcher_background', $style, time() + 31536000, '/', '.' . $host, '0');     } } function background_style_redirect() {     global $host;          if (!empty($_SERVER['HTTP_REFERER']))     {         header("Location: " . $_SERVER['HTTP_REFERER']);     }     else     {         header("Location: http://" . $host);     } } function background_style_files() {     global $background_style_directory, $extension;     $background_styles = array();     $i = 0;          if (is_dir($root . $background_style_directory))     {         if ($handle = opendir($root . $background_style_directory))         {             while (false !== ($file = readdir($handle)))             {                 if (strlen($file) > strlen($extension) && substr($file, strlen($file) - strlen($extension)) == $extension)                 {                     $background_styles[$i++] = $file;                 }             }                          closedir($handle);         }     }          if (count($background_styles) == 0)     {         $background_styles[0] = "No Stylesheets Found";     }     else     {         sort($background_styles);     }          return $background_styles; } function background_style_convert_file_to_title($file) {     global $extension, $special_character;          $title = ucfirst(trim(basename($file, $extension)));     $offset = 0;     while (true)     {         $offset = strpos($title, $special_character, $offset);         if ($offset === false)         {             break;         }         else         {             if (strlen($title) > ++$offset)             {                 if ($special_character != ' ')                 {                     $title = substr($title, 0, $offset - 1) . ' ' . ucfirst(substr($title, $offset, strlen($title)));                 }                 else                 {                     $title = substr($title, 0, $offset) . ucfirst(substr($title, $offset, strlen($title)));                 }             }         }     }          return $title; } function background_style_tabs($amount) {     global $tab;          for ($i = 0; $i < $amount; $i++)     {         echo $tab;     } } function background_style_form_open() {     global $linebreak;          echo '<form action="switcher_background.php" method="post">' . $linebreak; } function background_style_form_list($tabs) {     global $background_styles, $background_style_current, $linebreak;          echo '<select name="style">' . $linebreak;          for ($i = 0; $i < count($background_styles); $i++)     {         background_style_tabs($tabs + 1);         echo '<option value="' . $background_styles[$i] . '"';         if ($background_style_current == $background_styles[$i])         {             echo ' selected="selected"';         }         echo '>' . background_style_convert_file_to_title($background_styles[$i]) . '</option>' . $linebreak;     }          background_style_tabs($tabs);     echo '</select>' . $linebreak; } function background_style_form_button($label) {     echo '<input type="submit" value="';     echo empty($label) ? "Change" : $label;     echo '" />'; } function background_style_form_close() {     echo '</form>'; } $selection     = $_SERVER['QUERY_STRING']; $ip            = $_SERVER['REMOTE_ADDR']; $linebreak     = "\r\n"; $tab           = "\t"; $background_styles = background_style_files(); $background_style_current = background_cookie_read(); $host          = (substr($_SERVER['HTTP_HOST'], 0, 4) == 'www.') ? substr($_SERVER['HTTP_HOST'], 4, strlen($_SERVER['HTTP_HOST'])) : $_SERVER['HTTP_HOST']; if (basename($_SERVER['PHP_SELF']) == 'switcher_background.php') {     if ($_POST['style'] != null)     {         for ($i = 0; $i < count($background_styles); $i++)         {             if ($_POST['style'] == $background_styles[$i])             {                 background_cookie_write($_POST['style']);             }         }     }     background_style_redirect(); } ?> [/code] Here is the code for switcher_font.php [code] <?php $root = $_SERVER['DOCUMENT_ROOT'] . '/'; $font_style_directory = 'css/font/'; $extension = '.css'; $special_character = '_'; function include_font() {     global $host, $font_style_directory, $font_style_current, $linebreak;          echo '<link rel="alternative stylesheet" type="text/css" href="' . $font_style_directory . $font_style_current . '" title="User Defined Style" />' . $linebreak; } function font_cookie_read() {     global $font_styles;          if (isset($_COOKIE['switcher_font']))     {         return $_COOKIE['switcher_font'];     }     else if (count($font_styles) > 0)     {         return $font_styles[0];     }     else     {         return null;     } } function font_cookie_write($style) {     global $host;          if ($host == 'localhost')     {         setcookie('switcher_font', $style, time() + 31536000, '/');     }     else     {         setcookie('switcher_font', $style, time() + 31536000, '/', '.' . $host, '0');     } } function font_style_redirect() {     global $host;          if (!empty($_SERVER['HTTP_REFERER']))     {         header("Location: " . $_SERVER['HTTP_REFERER']);     }     else     {         header("Location: http://" . $host);     } } function font_style_files() {     global $font_style_directory, $extension;     $font_styles = array();     $i = 0;          if (is_dir($root . $font_style_directory))     {         if ($handle = opendir($root . $font_style_directory))         {             while (false !== ($file = readdir($handle)))             {                 if (strlen($file) > strlen($extension) && substr($file, strlen($file) - strlen($extension)) == $extension)                 {                     $font_styles[$i++] = $file;                 }             }                          closedir($handle);         }     }          if (count($font_styles) == 0)     {         $font_styles[0] = "No Stylesheets Found";     }     else     {         sort($font_styles);     }          return $font_styles; } function font_style_convert_file_to_title($file) {     global $extension, $special_character;          $title = ucfirst(trim(basename($file, $extension)));     $offset = 0;     while (true)     {         $offset = strpos($title, $special_character, $offset);         if ($offset === false)         {             break;         }         else         {             if (strlen($title) > ++$offset)             {                 if ($special_character != ' ')                 {                     $title = substr($title, 0, $offset - 1) . ' ' . ucfirst(substr($title, $offset, strlen($title)));                 }                 else                 {                     $title = substr($title, 0, $offset) . ucfirst(substr($title, $offset, strlen($title)));                 }             }         }     }          return $title; } function font_style_tabs($amount) {     global $tab;          for ($i = 0; $i < $amount; $i++)     {         echo $tab;     } } function font_style_form_open() {     global $linebreak;          echo '<form action="switcher_font.php" method="post">' . $linebreak; } function font_style_form_list($tabs) {     global $font_styles, $font_style_current, $linebreak;          echo '<select name="style">' . $linebreak;          for ($i = 0; $i < count($font_styles); $i++)     {         font_style_tabs($tabs + 1);         echo '<option value="' . $font_styles[$i] . '"';         if ($font_style_current == $font_styles[$i])         {             echo ' selected="selected"';         }         echo '>' . font_style_convert_file_to_title($font_styles[$i]) . '</option>' . $linebreak;     }          font_style_tabs($tabs);     echo '</select>' . $linebreak; } function font_style_form_button($label) {     echo '<input type="submit" value="';     echo empty($label) ? "Change" : $label;     echo '" />'; } function font_style_form_close() {     echo '</form>'; } $selection     = $_SERVER['QUERY_STRING']; $ip            = $_SERVER['REMOTE_ADDR']; $linebreak     = "\r\n"; $tab           = "\t"; $font_styles   = font_style_files(); $font_style_current = font_cookie_read(); $host          = (substr($_SERVER['HTTP_HOST'], 0, 4) == 'www.') ? substr($_SERVER['HTTP_HOST'], 4, strlen($_SERVER['HTTP_HOST'])) : $_SERVER['HTTP_HOST']; if (basename($_SERVER['PHP_SELF']) == 'switcher_font.php') {     if ($_POST['style'] != null)     {         for ($i = 0; $i < count($font_styles); $i++)         {             if ($_POST['style'] == $font_styles[$i])             {                 font_cookie_write($_POST['style']);             }         }     }     font_style_redirect(); } ?> [/code]
  3. [!--quoteo(post=377632:date=May 27 2006, 01:33 PM:name=448191)--][div class=\'quotetop\']QUOTE(448191 @ May 27 2006, 01:33 PM) [snapback]377632[/snapback][/div][div class=\'quotemain\'][!--quotec--] Pardon, but I tested your code (though very sloppy and way too long for it's intended pupose) and it works fine over here on IE, FF ánd Opera. I don't see the problem... Maybe you have FF set not to accept any cookies? [/quote] Ok, like I said this is my first time using PHP and I don't know what I am doing. I would appreciate suggestions on how to clean the code up and make it shorter, as opposed to just stating its sloppy and too long. By the way, [a href=\"http://www.designx.biz/test\" target=\"_blank\"]http://www.designx.biz/test[/a] works fine in FF. IE is the problematic browser. I have cookies enabled and default settings in both browsers. Could you double check [a href=\"http://www.designx.biz/test\" target=\"_blank\"]http://www.designx.biz/test[/a] in IE and make sure you can switch styles?
  4. [!--quoteo(post=377630:date=May 27 2006, 01:23 PM:name=Bob Leny)--][div class=\'quotetop\']QUOTE(Bob Leny @ May 27 2006, 01:23 PM) [snapback]377630[/snapback][/div][div class=\'quotemain\'][!--quotec--] Very interesting, you have more than what I thought. If you don’t mind, id like to run a couple of tests to check a couple of things. This will take me an hour or 2 though. [/quote] Sure thing, I really appreciate it. I do not know what I am doing with PHP, so you might be able to find a much more simplified way of doing this.
  5. [!--quoteo(post=377624:date=May 27 2006, 01:08 PM:name=Bob Leny)--][div class=\'quotetop\']QUOTE(Bob Leny @ May 27 2006, 01:08 PM) [snapback]377624[/snapback][/div][div class=\'quotemain\'][!--quotec--] I think I might know a much easier way to do this! could I see a coulple of your style sheets? [/quote] Here is a link to a ZIP file containing all the files: [a href=\"http://www.designx.biz/test/test.zip\" target=\"_blank\"]http://www.designx.biz/test/test.zip[/a]
  6. [!--quoteo(post=377614:date=May 27 2006, 12:50 PM:name=Bob Leny)--][div class=\'quotetop\']QUOTE(Bob Leny @ May 27 2006, 12:50 PM) [snapback]377614[/snapback][/div][div class=\'quotemain\'][!--quotec--] I think top play might be right. Try chageing this... [code]if ( ! session_is_registered("background") ) {     session_register("background");     $_SESSION['background'] = 'background_black';     $background = $_SESSION['background'];     } else {     $background = $_SESSION['background'];     }[/code] To this... [code] if (isset($_SESSION["background"]) ) {     $_SESSION['background'] = 'background_black';     $background = $_SESSION['background'];     } else {     $background = $_SESSION['background'];     } [/code] edit: I chaged it fro ! to the isset function which will check to see if the varieble exists [/quote] When I make these changes to the index.php file, it does not work in IE or Firefox.
  7. [!--quoteo(post=377603:date=May 27 2006, 12:15 PM:name=toplay)--][div class=\'quotetop\']QUOTE(toplay @ May 27 2006, 12:15 PM) [snapback]377603[/snapback][/div][div class=\'quotemain\'][!--quotec--] Don't use session_register() and $_SESSION. Read the third caution box here: [a href=\"http://us2.php.net/manual/en/function.session-register.php\" target=\"_blank\"]http://us2.php.net/manual/en/function.session-register.php[/a] Just use $_SESSION. [/quote] If I take out the session_register(), then how will it know which session to start? For each style change (background, font, etc.) I need to use an alterative style sheet. So, if someone clicks on "red" as a background color, then the PHP needs to replace the file name in the HTML so the red style sheet is loaded. [!--quoteo(post=377604:date=May 27 2006, 12:16 PM:name=Bob Leny)--][div class=\'quotetop\']QUOTE(Bob Leny @ May 27 2006, 12:16 PM) [snapback]377604[/snapback][/div][div class=\'quotemain\'][!--quotec--] Ok yeah, header("Cache-control: private"); is the fix to IE so place header("Cache-control: private"); imidetlly after the session_start(); on evrey page you have your sessions Like this <?php session_start(); header("Cache-control: private"); if ( ! session_is_registered("background") ) { [/quote] I tried putting header("Cache-control: private"); on every page and it still does not work in IE.
  8. [!--quoteo(post=377594:date=May 27 2006, 12:00 PM:name=Bob Leny)--][div class=\'quotetop\']QUOTE(Bob Leny @ May 27 2006, 12:00 PM) [snapback]377594[/snapback][/div][div class=\'quotemain\'][!--quotec--] <?php session_start(); header("Cache-control: private"); Are you useing the header(); after the session_start(); ? [/quote] I updated my original post to include the PHP code, let me know if this answers your question.
  9. The goal is to design an W3C and Section 508 standards-compliant web site that gives the user the ability to customize the look and feel by selecting options from a drop-down list. I am a front-end designer, fluent in CSS and XHTML, but I have no experience with forms or back-end scripting. This is where I need help. Here is the link to a demo of what I am trying to do: [a href=\"http://www.designx.biz/test\" target=\"_blank\"]http://www.designx.biz/test[/a] If you open the above link in Firefox and start clicking through the links, then you should see how the site "remembers" your preferences as you go along. You can customize the style of the site to your liking, which should prove for a more enjoyable user experience. If you open the above link in Internet Explorer, however, then it does not change the styles when you click on the links. This is a problem. I chose to use standard hyperlinks for this demo, though I would like to make it work with XHTML drop-down form menus once I get the PHP working. Here is a link to a ZIP file containing all the files in the above demo: [a href=\"http://www.designx.biz/test/test.zip\" target=\"_blank\"]http://www.designx.biz/test/test.zip[/a] I am willing to keep an open mind, so feel free to suggest alternative means to meet my goal. The thought of storing the style preferences in cookies also crossed my mind, because it would be cool for the site to "remember" your style preferences if you re-visit the site after several reboots and a few days time. I am sure you all can see where I am going with this, so I hope you can help me! Here is the code from switcher_background.php: [code] <?php session_start(); if ( ! session_is_registered("background") ) {     session_register("background");     $_SESSION['background'] = 'background_black';     $background = $_SESSION['background'];     } else {     $background = $_SESSION['background'];     } if ( ! session_is_registered("color") ) {     session_register("color");     $_SESSION['color'] = 'color_yellow';     $color = $_SESSION['color'];     } else {     $color = $_SESSION['color'];     } if ( ! session_is_registered("size") ) {     session_register("size");     $_SESSION['size'] = 'size_small';     $size = $_SESSION['size'];     } else {     $size = $_SESSION['size'];     } if ( ! session_is_registered("font") ) {     session_register("font");     $_SESSION['font'] = 'font_verdana';     $font = $_SESSION['font'];     } else {     $font = $_SESSION['font'];     } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>StyleSheet Switcher</title> <link rel="stylesheet" type="text/css" href="screen.css"> <link rel="alternative stylesheet" type="text/css" href="<?php echo $background ?>.css" title="User Defined Style"> <link rel="alternative stylesheet" type="text/css" href="<?php echo $alignment ?>.css" title="User Defined Style"> <link rel="alternative stylesheet" type="text/css" href="<?php echo $color ?>.css" title="User Defined Style"> <link rel="alternative stylesheet" type="text/css" href="<?php echo $size ?>.css" title="User Defined Style"> <link rel="alternative stylesheet" type="text/css" href="<?php echo $font ?>.css" title="User Defined Style"> </head> <body> Change Background Color<br> <a href="switcher_background.php?background=background_black">Black</a><br> <a href="switcher_background.php?background=background_red">Red</a><br> <a href="switcher_background.php?background=background_green">Green</a><br> <a href="switcher_background.php?background=background_blue">Blue</a><br> <br>Change Alignment<br> <a href="switcher_alignment.php?alignment=alignment_left">Left</a><br> <a href="switcher_alignment.php?alignment=alignment_center">Center</a><br> <a href="switcher_alignment.php?alignment=alignment_right">Right</a><br> <br>Change Font Size<br> <a href="switcher_size.php?size=size_small">Small</a><br> <a href="switcher_size.php?size=size_medium">Medium</a><br> <a href="switcher_size.php?size=size_large">Large</a><br> <br>Change Font Color<br> <a href="switcher_color.php?color=color_yellow">Yellow</a><br> <a href="switcher_color.php?color=color_white">White</a><br> <br>Change Font<br> <a href="switcher_font.php?font=font_verdana">Verdana</a><br> <a href="switcher_font.php?font=font_georgia">Georgia</a> </body> </html> [/code] Here is the code from switcher_background.php: (there are individual switchers for each style change) [code] <?php session_start(); if ( ! session_is_registered("background") ) {     session_register("background");     } $_SESSION['background'] = $_GET['background']; header("Location: ".$_SERVER['HTTP_REFERER'] ); ?> [/code]
×
×
  • 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.