Jump to content


This topic is now archived and is closed to further replies.


Help returning values from a checkbox to email

Recommended Posts

Hi, I have a page http://www.athene-hairandbeauty.co.uk/appointment.html with a number of checkboxes. What I need to do is allow the user to check the boxes and when submit is clicked the data is sent to an email address. How can I achieve this have done it before with textboxes etc., but with the checkboxes no data is passed. Think I need an array in my php, any ideas how I can achieve this. The following is code to what I used when using textboxes, hope someone can point me in the right direction. Cheers guys.

$option = $_POST["SalonVsPrices_Key"];
$email = $_POST["email"];
$message = $_POST["message"];
$date = date ("j m Y hh:mm", strtotime("now"));
$message = $_POST["message"];
$message = <<<EOF
Enquiry from $name \r\n
Email address: $email\r\n
Made on $date\r\n
who left the following message: \r\n


$to = "enquiries@exploitation.org.uk"; // To email address
$subject = "Enquiry from Athene Hair and Beauty Contact Page";
$headers = 'From: $to'. "\r\n" .
'Reply-To: $to' . "\r\n" .
'X-Mailer: PHP/' . phpversion();

if(mail($to, $subject, $message, $headers))
header("Location: ContactResponse.html");
echo "error in mail";

Share this post

Link to post
Share on other sites
Do you use an array to build your checkbox listing

[code=php:0]        foreach ($filen as $value){
            echo "<input type='checkbox' name='chkbx[]' value='".$value."' checked>$value<br>";
        } [/code]

If so you will need a foreach loop or something the get the values back out

If you build is one line at a time the maybe your displaying the value to the screen but not setting the variable to it

example of display and setting variables
            echo "<input type='checkbox' name='chkbx1' value='opt1' checked>Option 1<br>";
            echo "<input type='checkbox' name='chkbx2' value='opt2'>Option 2<br>";


example on display only
            echo "<input type='checkbox' name='chkbx1' checked>Option 1<br>";
            echo "<input type='checkbox' name='chkbx2'>Option 2<br>";


Share this post

Link to post
Share on other sites
in your case not passing data from unchecked checkboxes is a good thing.

I checked your page and it looks like all of your checkboxes have the same name. they need to be different, or the values will just overwrite themselves.

This will only send the item name and the price of the items selected. if the items aren't selected by the visitor, they don't come through.

[code=php:0]<input type="checkbox" name="Haircut with shampoo with Norah" value="21.95">[/code]

Share this post

Link to post
Share on other sites


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.