I have an assignment due for class. It's PHP programming course that's supposed to be okay if you have a semester of programming in your background. I have that semester, but I'm finding the simple tasks to be too challenging.
Here is what I'm being asked to do:
In this part you will create a set of pages that could be used to test different text and background color combinations. Your first page should contain a form with two selection lists: one for the background color, and one for the text color. Your second page should process this form, displaying some sample text in the desired color with the desired background color. In addition, your program should display an error message (in black text on a white background) if the user selects the same color for both text and background. The specific colors you have in your selection lists are up to you, but you should have at least five colors in each list.
Here is the HTML:
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>Colors</title>
</head>
<body>
<!-- Week 3 Homework -->
<div>
<p>Fill out the following fields:</p>
<form action="colorsForm.php" method="post">
<div>
<p>Text Color:
<select name="tColor">
<option value="">Pick One...</option>
<option value="red">Red</option>
<option value="orange">Orange</option>
<option value="brown">Brown</option>
<option value="grey">Grey</option>
<option value="green">Green</option>
</select>
Background Color:
<select name="bColor">
<option value="">Pick One...</option>
<option value="red">Red</option>
<option value="orange">Orange</option>
<option value="brown">Brown</option>
<option value="grey">Grey</option>
<option value="green">Green</option>
</select>
</p>
<input type="submit" name="submit" value="Submit" />
</div>
</form>
</div>
</body>
</html>
Here is my PHP:
<?php //colorsForm.php
//This page retrieves the data from finalGrade.php
//bColor, tColor and submit in $_POST.
$tColor = $_POST['tColor'];
$bColor = $_POST['bColor'];
if ($tColor == $bColor) {
print '<p style="color:black; background-color:white">You have to select two different colors in order to see the text.</p>';
} else {
print '<p style="background-color:$bColor; color:$tColor;></p>';
}
?>
If I select the same color for both text and background it produces the error the way I want it. The problem is when I select different values nothing shows up at all. I can't figure out how to get the background colors and text colors to show up. I originally had two switch statements that would show the text color and background color but on different lines.
Any help would be appreciated
Thank You