education81 Posted December 17, 2009 Share Posted December 17, 2009 Hi I have recently implemented a style sheet switcher to my site and is nearly complete. I am very new to php so please be patient. I have an index page that has the following <form action="http://www.freestormtracker.com/scripts/s3.php" method="get"> <label for="style">Style:</label> <select id="style" name="style"> <?php foreach ($available_styles as $_style) { printf('<option value="%s"%s>%s</option>', $_style, ($_style == $style) ? ' selected="selected"' : '', ucfirst($_style)); } ?> </select> <input type="submit" value="switch" /> </form> This form also uses two other pages called s3.php and s3.cfg.php S3 looks like <?php // vim:et ts=4 sw=4 cindent: if (!@include('s3.cfg.php')) die("Unable to include config file!"); $set_cookie = true; if (isset($_GET['style'])) { $style = $_GET['style']; } elseif (isset($_POST['style'])) { $style = $_POST['style']; } elseif (isset($_COOKIE['style'])) { $style = $_COOKIE['style']; $set_cookie = false; } // if no style supplied, or invalid supplied... if (!isset($style) || !in_array($style, $available_styles)) { // set style to default (first available) $style = $available_styles[0]; } // our cookie will last 2 years... modify // the last argument if this isn't sufficient if ($set_cookie) setcookie('style', $style, mktime() + 2 * 356 * 24 * 60 * 60, '/', '.freestormtracker.com'); $referrer = (!empty($_SERVER['HTTP_REFERER'])) ? $_SERVER['HTTP_REFERER'] : $default_referrer; header('Location: ' . $referrer); ?> and s3.cfg.php <?php // vim:et ts=4 sw=4 cindent: $style_path = 'http://www.freestormtracker.com/style/'; $available_styles = array( 'red', 'default' ); $default_referrer = '/'; ?> All i want is the index page to have clickable images instead of a dropdown selection but i have no idea how to do this. Ant help is very much appreciated. Quote Link to comment https://forums.phpfreaks.com/topic/185416-really-frustrating/ Share on other sites More sharing options...
mikesta707 Posted December 17, 2009 Share Posted December 17, 2009 well since you send it via get, you can make a link, (which would go to whateverpage.php (this is your action attribyte) and at the end of that you put ?style=$watever) not to hard to change the code you have with images. just change the option tags to <a> tags wrapped around img tags Quote Link to comment https://forums.phpfreaks.com/topic/185416-really-frustrating/#findComment-978839 Share on other sites More sharing options...
education81 Posted December 17, 2009 Author Share Posted December 17, 2009 I have no idea how to call the individual style because this script also calls a cookie to see if it is set or not. all i need is how one link i.e <a href="?">Change To Blue</a"> should be written and my sites finished,,, its had me stumped for days. Quote Link to comment https://forums.phpfreaks.com/topic/185416-really-frustrating/#findComment-978857 Share on other sites More sharing options...
roopurt18 Posted December 17, 2009 Share Posted December 17, 2009 <a href="/style_switcher.php?style=blue"><img src="blue.png" alt="Blue Style" /></a> <a href="/style_switcher.php?style=silver"><img src="silver.png" alt="Silver Style" /></a> <a href="/style_switcher.php?style=red"><img src="red.png" alt="Red Style" /></a> You can output links like that and then style_swither.php, or whatever script you want to link to, can perform the logic of setting the cookie and redirecting to an appropriate page. Quote Link to comment https://forums.phpfreaks.com/topic/185416-really-frustrating/#findComment-978866 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.