Im trying to write a contact form and so far everything works only theres a multiple checkbox in the form and im unsure how to call all data and so my email returns 'array' for the variable 'service'
My code is...
<?php
$name = $_POST['name'];
$email = $_POST['email'];
$number = $_POST['number'];
$service = $_POST['service'];
$description = $_POST['description'];
$location = $_POST['location'];
$to = "[email protected]";
//begin of HTML message
$message = "
From : $name,
Email: $email,
Number: $number,
Service: $service,
Description: $description
Location: $location
";
//end of message
$headers = "MIME-Version: 1.0rn";
$headers .= "Content-type: text/html; charset=iso-8859-1rn";
$headers .= "From: $email\r\n";
mail($to, $subject, $message, $headers);
?>
My form for the service input is...
<dt><input type="checkbox" value="Static guarding" name="service[]" class="cbox">Static guarding</dt>
<dt><input type="checkbox" value="Mobile Patrols" name="service[]"class="cbox">Mobile Patrols</dt>
<dt><input type="checkbox" value="Alarm response escorting" name="service[]"class="cbox">Alarm response escorting</dt>
<dt><input type="checkbox" value="Alarm response/ Keyholding" name="service[]"class="cbox">Alarm response/ Keyholding</dt>
<dt><input type="checkbox" value="Other" name="service[]"class="cbox">Other</dt>
<dt><input type="hidden" value="Other" name="service[]"class="cbox"></dt>
var_dump($_POST['service']);to view the structure of the array within the$_POSTarray. You have a multi-dimensional array here.$email. I'd suggest usingFILTER_SANITIZE_EMAILwithfilter_input()orfilter_var()from the Filter extension.