dthomas31uk Posted September 15, 2006 Share Posted September 15, 2006 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 = <<<EOFEnquiry from $name \r\nEmail address: $email\r\nMade on $date\r\nwho left the following message: \r\n$messageEOF;$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");exit;}else{echo "error in mail";};"; Quote Link to comment Share on other sites More sharing options...
jvrothjr Posted September 15, 2006 Share Posted September 15, 2006 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 outIf you build is one line at a time the maybe your displaying the value to the screen but not setting the variable to itexample of display and setting variables[code=php:0] echo "<input type='checkbox' name='chkbx1' value='opt1' checked>Option 1<br>"; echo "<input type='checkbox' name='chkbx2' value='opt2'>Option 2<br>";[/code]example on display only[code=php:0] echo "<input type='checkbox' name='chkbx1' checked>Option 1<br>"; echo "<input type='checkbox' name='chkbx2'>Option 2<br>";[/code] Quote Link to comment Share on other sites More sharing options...
michaellunsford Posted September 15, 2006 Share Posted September 15, 2006 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] Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.