tags:

views:

101

answers:

3

How do I set this up so that I can manipulate $backgroundcolor = "#00FFFF"; on another .php file?

Initially I just want to be able to change the value of the $backgroundcolor ="#00FFFF"; From another form that is hrefed to this form (style.php) based on user input.

I Tried this on this form so that I could hopefully give $backgroundcolor different values: $backgroundcolor = " ";

Then I used another .php form that is hrefed to this style.php script to call $backgroundcolor ="some different hex color with no results";

In fact all I saw was the output of the value #0033FF, but I don't want the output, I want the new value #0033FF to be the background color?

<?php header("Content-type: text/css"); 
$backgroundcolor = "#00FFFF ";
$textcolor = " #0033FF";
?>
body {
 background:<?php  echo $backgroundcolor?>;
 color:<?php echo $textcolor?>;
}
+2  A: 

You could use sessions, cookies, databases.

What you are trying to do is to persist some data through requests.

You have to store the background & text color somewhere, at your convenience.

Boris Guéry
... and re-set it in the other script.
Martin Hohenberg
A: 

It also seems to wrong way of changing colors with PHP. You should try to solve the changing of background-colors with Javascript, as soon as the page has loaded.

PHP is not meant for DOM manipulation, Javascript is.

Maybe that's not your real problem but it's hard to get what you're trying to do. What does hrefed mean for you? Just linked or posted to?

tharkun
+1  A: 

Use this on the php side:

The idea is to get all the css and php code setup like this:

$backgroundcolor = $_REQUEST["backgroundcolor"];

background-color:$backgroundcolor;

Where background-color: will give you the color of the background in traditional CSS, we will use this with a variable, in this case $backgroundcolor;

On the html side we will have a form like this:

<select name = "backgroundcolor">
<option value = "#000000">Black</option>
<!-- And all we have to do is add multiple options for the different color values      
and the php script will do the rest after the user has selected 
the color he or she wants, done-->


#heredoc
$theStyle = <<<HERE
"border-width:$borderSize$sizeType;
background-color:$backgroundcolor;
color:$fontcolor;
border-style:$borderStyle;
border-color:green"
HERE;
Newb