0

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
  • I don't understand what you're trying to do. What does PHP have to do with CSS? And what do you mean by manipulating $backgroundcolor on another php file? Would you be including another php file? Commented Oct 21, 2009 at 10:01
  • Your explanation is bad. Please rephrase your explanation as it is really difficult to understand. Commented Oct 21, 2009 at 10:22

2 Answers 2

2

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.

Sign up to request clarification or add additional context in comments.

1 Comment

... and re-set it in the other script.
1

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;

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.