PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
i would like to know how to do this...i have a dropdown list with 3 options...the first choose an option, 2nd is option1, 3rd is option2...now, upon inserting to the database, i like the default option(choose an option) not to be written to the database and instead, a message will prompt the user to select one option...so far my dropdown code is below..any modifications that will help is very much appreciated...thanks in advance..
//check for category of organization
if (empty($_POST['category']))
{
$c = false;
$message .= 'Please select at least one category<br>';
}
else
{
$c = $_POST['category'];
}
when i tried not to select anything, it perfectly worked...unfortunately, when i tried to supply or select a detail, the error message of $message appears and prompting me to select at least one role....
You sure did set the default value for your selectbox but did not put any more options. Only the default option has a value attribute while the others don't have.
You need to change that part into ...
I wrote:
<option value="0" selected>Please choose a role</option>
<option value="1">Contractor</option>
<option value="2">Sub-Contractor</option>
<option value="3">Outsourcing</option>