Jump to content

Question About Php And Css...


id

Recommended Posts

Ok, this is my question:

 

What is the best way to change the theme of a site (coding wise)?

 

Example, if the users wants to a certain theme, then an option would come up to pick their theme. However, another user wont get the theme change (just like IPB).

 

How would i code that option?

1. Would i have to code the css in php... So instead of style.css it will be style.php

 

2. On the settings file, it will have an option for the user to pick a theme using a dropdown menu . So if the user selects the all red background, then $default_css = $_POST["theme_selection"];

 

3.

<link rel=StyleSheet href="<?php $default_css; ?> " type="text/css" />

 

or is their a simplier way and or a smarter way of achieving this?

Link to comment
Share on other sites

oh this is easy

 

OK so I am assume you have different files or CSS themes or what not already design

so before the theme is set

 

<?php

if(!isset($_COOKIE['theme']))

setcookie("theme", $default_css);

 

if(isset($_POST["theme_selection"])){

$default_css = $_POST["theme_selection"];}

else{$default_css = "defaultbalagahalsdjjaklsd";}

 

 

 

?>

 

<link rel=StyleSheet href="<?php $default_css; ?> " type="text/css" />

 

then on every page

<?php

if(isset($_COOKIE["theme"])){

 

 

$default_css = $_COOKIE['theme'];

else{$default_css = "defaultbalagahalsdjjaklsd";}

?>

<link rel=StyleSheet href="<?php $default_css; ?> " type="text/css" />

Or something like that! Hope that helps!

Link to comment
Share on other sites

No, just that you make sure to verify that what you get from them is what you expect. Cookies are perfectly fine for what you're using them to, but what happens if a user changes (or have it silently changed by someone else) to a filename that doesn't exist? Or worse, an XSS attack?

That's why you need to validate the input, and check that the file exists.

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.