The page color is changing color to the correct value in the selection list but the text/font color is not working. Any assistance that can be provided to resolve this is greatly appreciated.
Here is the contents of the text file: color.txt
Code: Select all
red
blue
white
Code: Select all
<body>
<form action="pageColor2.php" method="post">
Please select a page color<br><br>
<?php
include "activity2.php";
?>
<br><br>
<input type="submit" id="button1" name="button1" />
</form>
</body>
Code: Select all
<?php
// Assigns the content of "colors.txt" to $colorsArray.
$colorsArray = file("/path to/colors.txt");
// Assigns $color to the selection in the options list.
$color = $_POST['color'];
// If the submit button is activated then:
if (isset ($_POST["button1"])){
// The beginning of the select control.
echo "<select name='color' id='color'>";
// Loop through each value of the array and print it as an option element.
foreach($colorsArray as $value) {
// Explodes the color.txt file.
$colorsArray = explode(" ", $value);
// Assigns each value of the $colorsArray to $color ($_POST['color])
$colorsArray = $color;
echo "<option value='$value' selected='selected'>$value</option><br>";
}
// The end of the select control.
echo "</select>";
/* This is wnere the code appears to fail */
if ($color == $colorsArray[0][0] || $colorsArray[0][1]){// I am getting an error on this line.
echo "<body style='background-color:$color; color: white;'>";
}else
// Changes the page color to the value selected.
echo "<body style='background-color:$color; color: black;'>";
}// if(isset ($_POST["button1])).
print_r ($colorsArray);
?>
Code: Select all
(
[0] =>
)
Code: Select all
(
(
[0] => red
)
(
[0] => blue
)
(
[0] => white
)
)