[PHP] Re: problems trying to use PHP to choose CSS
On Sat, 30 Mar 2002, Hugh Bothwell wrote: Thanks to Hugh for his help... his PHP code was perfect... it was exactly what it took to get it done. Just a few minor notes: I was able to keep the echo EOD statements which I prefer for this particular implementation, and I kept form action=$PHP_SELF method='post' so that it would pass validation... (missing an 'action' was causing an error). That said, it was Hugh's PHP code that took this from being a thought I had to actually working. My thanks to him. Reverting to lurklearn mode for the time being :-) TjL -- Site: www.tntluoma.com mailto:[EMAIL PROTECTED] Info: Apache/1.3.19 (Unix) with PHP/4.0.6 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: problems trying to use PHP to choose CSS
I am trying this method: Register a global variable ($CSS) using a FORM. [snip] I wonder if I am not doing something stupid/overlooking something obvious, but I am very new PHP so that is possible. // in my global PHP file // Now what I am trying to do here is set a default that should ONLY be // used if the $CSS variable is NOT already set if (!isset($CSS)) { // if it is not set, then and only then set it and define it session_start(); session_register(CSS); $CSS=global; } 1. session_start() should called every time, ie not inside a conditional clause. 2. I'm not sure that giving the form-return value and the session value the same name is a good idea. 3. I think a lot of the double-quotes in your echoed text were screwing things up. Try something like: ?php// HEADER session_start(); // new session? set default value if (!session_is_registered(CSS)) { session_register(CSS); $CSS = global; } // setting changed by form? update session value if (isset($newCSS)) $CSS = $newCSS; ? !-- USAGE -- link type='text/css' rel='stylesheet' href='/global/css/?php echo $CSS; ?.css' / !-- FOOTER -- pChoose style: form method='post'!-- default action is get-to-self -- select name='newCSS' option value='default' selectedDefault/option option value='smaller'Smaller/option option value='tamecolors'Tamer Colors/option option value='print'Print/option /select input alt='Set Style' type='submit' name='Set Style' value='Set Style' / /form /p pCurrent style is: strong?php echo $CSS; ?/strong/p -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php