Forum Moderators: coopster
if $_POST['bordercolor'] = "none"
then bordercolor = $_POST['bg_color']
else bordercolor = $_POST['bordercolor']
I cannot get it to pass the variable twice, I am assuming this is a PHP limitation. So I tried changing the variable name like so:
$_POST['bordercolor] = &$bordercolor
$_POST['bg_color] = &$background
and changing the code to:
if $_POST['bordercolor'] = "none"
then bordercolor = $background
else bordercolor = $bordercolor
But it does not pass any values, the bordercolor comes back with a value of "". I know the syntax isn't correct, but I type the shortened version for time purposes. Should this work?
Welcome to WebmasterWorld!
Your if/else control structure has me a little confused. Check it out in the manual [php.net] and you'll see what I mean.
if ($_POST['bordercolor'] == "none") {
$bordercolor = $_POST['bg_color'];
}
else {
$bordercolor = $_POST['bordercolor'];
}
I'm surprised you're not getting some sort of error.
Thanks for being careful about posting code. I think the only way to get to the bottom of your problem is for you to show us the relevant parts of your php. Here's the guide for posting code.
[webmasterworld.com...]
Tim
<?
$_POST['bg_color'] = &$background;
$_POST['border'] = &$bordercolor;
?>
I'm confused by what you're trying to do here with assigning the POST variables by reference to these other variables.
Can we back up and figure out why your first idea didn't work?
$background = $_POST['bg_color'];
if ($_POST['border'] == "none") {
$bordercolor = $background;
}
else {
$bodercolor = $_POST['border'];
}
I hope that's in line with what you're trying to do.
The $_POST array variables persist as long as the script is running. It's true that if you click a link or redirect, you may lose them, but certaintly I can say
$color1 = $_POST['color'];
$color2 = $_POST['color'];
$color3 = $_POST['color'];
All day long. Or actually, for any amount of time up to server timeout, which is less than all day.
Timotheos is right. Let's look at your original script again, since it should work without passing by reference.
One thought. What level of error reporting do you have in your php.ini?
Try it with E_ALL. That will flag any undefined variables and array indices. I'm betting on a typo?
Tom
<?=$_POST['color3'];?>
But mine uses:
<?=$_POST['color3']?>
This may be the problem. B.T.W. - This is php within HTML, so keep that in mind.