How can I use PHP to raise an error if this particular value is selected?
<option>Please Select</option>
Check if $_POST is empty
Html:
<select name="category">
<option value="">Please Select</option>
<option value="1">Category 1</option>
<option value="2">Category 2</option>
</select>
and php:
if (empty($_POST['category']) && isset($_POST['category'])) {
echo 'Error, select category';
exit;
}
$_POST'ed data in PHP? give it a value and use==or useempty()and set the value of this option to nothing, like:value=""as shown in atmon3r's answer.requiredattribute on the select element. Will catch some simple errors and in combination with PHP be a good experience for your user.