我这里有一个下拉菜单:
$pHTML = "";
$moduledrop = isset($_POST['modules']) ? $_POST['modules'] : '';
$moduleHTML .= '<select name="modules" id="modulesDrop">'.PHP_EOL;
$moduleHTML .= '<option value="">Please Select</option>'.PHP_EOL;
....
$moduleHTML .= '</select>';
....
<form action="<?php echo htmlentities($_SERVER['PHP_SELF']); ?>" method="post">
<table>
<tr>
<th>Module: <?php echo $moduleHTML; ?></th>
</tr>
</table>
<p><input id="moduleSubmit" type="submit" value="Submit Module" name="moduleSubmit" /></p>
</form>
我的问题很简单,如果用户选择Please Select
下拉菜单并提交,它应该显示Please Select a Module
消息。但它没有显示此消息。为了做到这一点,我需要在下面的代码中进行哪些更改:
if (isset($_POST['moduleSubmit']) || isset($_POST['sessionSubmit'])){
if($_POST['modules'] == ''){
$pHTML = "<span style='color: red'>Please Select a Module</span>";
}else if($sqlnum == 0){
$pHTML = "<span style='color: red'>Sorry, You have No Assessments under this Module</span>";
} else{
$pHTML = "<span style='color: green'>Assessment Successfully Found</span>";
$assessmentform = "<div id='lt-container'>
<form action='".htmlentities($_SERVER['PHP_SELF'])."' method='post' id='assessmentForm'>
<p id='warnings'>{$pHTML}</p>
<p><input id="sessionSubmit" type="submit" value="Submit Assessment" name="sessionSubmit" /></p>
</form>
</div>";
echo $assessmentform;
}
}