Okay, so I have a html form, and a using php for the server side validation to send the information from the form as an email. I cannot, for the life of me, get the form to send the items as an array.
Here's my html:
<select multiple name="symptoms[]">
<option value="ADHD">ADHD</option>
<option value="Insomnia">Insomnia</option>
<option value="Depression">Depression</option>
<option value="PTSD">PTSD</option>
<option value="Autism">Autism</option>
<option value="Stress">Stress</option>
<option value="Addiction">Addiction</option>
<option value="Pain">Pain/Headaches</option>
Here's my php in which I think the problem lies:
// validation expected data exists
if(!isset($_POST['first_name']) ||
!isset($_POST['last_name']) ||
!isset($_POST['email']) ||
!isset($_POST['telephone']) ||
!isset($_POST['symptoms']) ||
!isset($_POST['location']) ||
!isset($_POST['comment'])) {
died('We are sorry, but there appears to be a problem with the form you submitted.');
}
$first_name = $_POST['first_name']; // required
$last_name = $_POST['last_name']; // required
$email_from = $_POST['email']; // required
$telephone = $_POST['telephone']; // not required
$symptoms = $_POST['symptoms']; // not required
$location = $_POST['location']; // not required
$comments = $_POST['comment']; // required
There is also this section of php, but I don't think the 'symptoms' area is a problem here...
function clean_string($string) {
$bad = array("content-type","bcc:","to:","cc:","href");
return str_replace($bad,"",$string);
}
$email_message .= "First Name: ".clean_string($first_name)."\n";
$email_message .= "Last Name: ".clean_string($last_name)."\n";
$email_message .= "Email: ".clean_string($email_from)."\n";
$email_message .= "Telephone: ".clean_string($telephone)."\n";
$email_message .= "Symptoms: ".clean_string($symptoms)."\n";
$email_message .= "Location: ".clean_string($location)."\n";
$email_message .= "Comment: ".clean_string($location)."\n";
I have been trying to change the !isset all day and the $symptoms lines to get the 'symptoms' select multiple to show up on my email as an array. Right now it just says "array" in the email. I was thinking maybe the .clean-string should be something to do with array instead of string? I'm completely stuck, I've tried everything I can find, copied and pasted and tinkered and changed about 5 different sets of codes I found on stackoverflow...