css - User defined background color using PHP -
i'm trying figure out how change background color of table using php. know have value's wrong somewhere can't figure out where. think i'm in ballpark of getting right i'm missing where. appreciated.
background color:
<form action= "post3.php" method="post"> author * : <input type="text" name="author"><br/> email : <input type="text" name="email"><br/> title * : <input type="text" name="title"><br/> background color: <input type = 'radio' name ='bgcolor' value= 'blue' <?php print $blue_status; ?> >blue <input type = 'radio' name ='bgcolor' value= 'red' <?php print $red_status; ?> >red <p> tag: <input type="checkbox" name="tag[]" value="general interests"> general interests <input type="checkbox" name="tag[]" value="local schools"> local schools <input type="checkbox" name="tag[]" value="safety"> safety <br/> <select name="city" id="city"> <option value="0" selected="selected">select city</option> <option value="arlington">arlington</option> <option value="dallas">dallas</option> <option value="ft. worth">fort worth</option> </select> <br> comment * : <br/><textarea name="comment" rows="5" cols="40"></textarea><br> <input type="submit" name="submitthis" value="preview"> </form>
php:
$blue_status = 'unchecked'; $red_status = 'unchecked'; if (isset($_post['submitthis'])) { $selected_radio = $_post['bgcolor']; if ($selected_radio == 'blue') { $blue_status = 'bluebg'; } else if ($selected_radio == 'red') { $red_status = 'redbg'; } }
the table:
$output = "<table border=\"1\" style=\"width:30%\"> <tr> <td>author:</td> <td>$author</td> </tr> <tr> <td>title:</td> <td>$title</td> </tr> <tr> <td>tag:</td> <td>$tagstr</td> </tr> <tr> <td>city:</td> <td>$cities</td> </tr> <tr> <td>comment:</td> <td>$comment</td> </tr> </table> ";
css:
.redbg{ background-color: indianred; } .bluebg{ background-color: lightblue; }