Forum Moderators: coopster
All the information is being passed fine, but I'm having trouble with the checkboxes. I've got the info to pass if I set the checkbox to "checked" but it's not appropriate to do this - I have a list of 8 checkboxes.
Is there a way that php can handle this, or do I need to use javascript? If so can someone point me in the right direction. Thanks.
Also the radio buttons aren't passing information either, but I'm assuming that its the same reason.
I'm using code like this
name="field[]" "value="choice1"
name="field[]" "value="choice2"
anyways if it is what i think you mean (probally is not)
you could do this <input type=checkbox name=blah <?if (value == 'thevalueifitischecked'){echo"checked";}?>>
I've also tried to search through other posts and I'm now realising just how much I don't know!
This is the code I'm using:
--------------------------
if ($_POST) {
if (get_magic_quotes_gpc()) {
foreach ($_POST as $key => $value) {
$temp = stripslashes($value);
$_POST[$key] = $temp;
}
}
$to = 'email@example.com';
$subject = 'Feedback from website';
// message goes here
$message = "Contact: " . $_POST['eventtype'] . "\n";
$message .= "Event Date: " . $_POST['eventdate'] . "\n";
// headers go here
$headers = "From: feedback@example.com\n";
$headers .= "Reply-To: " . $_POST['email'] . "\n";
$headers .= "Cc: email@example.com\n";
$headers .= "Content-type: text/plain; charset=UTF-8";
$sent = mail($to, $subject, $message, $headers);
}
----------------------------------------------
<dt>
<label for="Service">Service</label>
</dt>
<dd>
<input type="checkbox" name="service[]" value="service1" >
Service 1 </dd>
<dd>
<input type="checkbox" name="service[]" value="service2" >
Service 2 </dd>
--------------------------------------------
It's now sending the word "Array" via email.
Do I need to use a forloop, or something else? Any help would be great, thanks.