I have a contact page and I would like to add certain options when filling out the form. Like this
<select>
<option value=“media”>select option</option>
<option value=“music”>option 1</option>
<option value=“movie”>option 2</option>
</select>
But I don’t know how to send the option that the user has selected to my email. What do i need to do to my php file to send the value they selected? thanks.
Also, how do make it mandatory for the user to select an option?
<?php
$myemail = “”;
$email = check_input($_POST[‘email’]);
$message = check_input($_POST[‘message’], “Write your message”);
if (!preg_match(“/([\w\-]+\@[\w\-]+\.[\w\-]+)/”, $email))
{
show_error(“E-mail address not valid”);
}
With regards to making selecting an option mandatory, I guess you could set your first option to trigger an error.
<option value=“error”>Please select an option</option>
Then test if the option value is “error” and echo an error.
if ($_POST['type'] = 'error'){
//whatever you want to do to echo out the error message
}
if (!preg_match(“/([\w\-]+\@[\w\-]+\.[\w\-]+)/”, $email))
{
show_error(“E-mail address not valid”);
} if ($_POST[‘type’] = ‘error’)
{
show_error(“Please select a type”);
}