[SOLVED] Form to email script with checkboxes

This is a discussion on "[SOLVED] Form to email script with checkboxes" within the PHP Forum section. This forum, and the thread "[SOLVED] Form to email script with checkboxes are both part of the Program Your Website category.


 Subscribe in a reader

Go Back   Webforumz.com > Main Forums > Program Your Website > PHP Forum

Notices




Reply
 
LinkBack Thread Tools
  #1  
Old Dec 9th, 2007, 09:22
Junior Member
Join Date: Nov 2007
Location: Oregon
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
[SOLVED] Form to email script with checkboxes

I have created a consultation request form which has mostly text fields, a few radio buttons and two somewhat large areas of checkboxes.

I have almost finished with the php script to send the results of the form to email.

My problem is dealing with the checkboxes. They are not grouped, like the radio buttons, so I assume that they can't be grouped in the e-mail?

Ideally I would like to have only the checked boxes come through on the email. And, ideally, these checked boxes would be in the two groups.

Can anyone steer me in the general direction of how to go about this? (Both parts - the "checked only" and/or the "grouped") I have scoured this site and the internet in general with no luck.

Yes, I am very new to this and I really appreciate your help! Thanks!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote

  #2  
Old Dec 9th, 2007, 16:03
Highly Reputable Member
Join Date: Sep 2007
Age: 15
Posts: 717
Blog Entries: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Form to email script with checkboxes

Well, for the checkboxes to come through the email, you would need to GET them first. Like this:
PHP: Select all

$checkbox1 $_POST['option1'];
$checkbox2 $_POST['option2'];
// etc... 
Assuming your HTML is the following:
HTML: Select all
<input type="checkbox" name="option1" value="checked value 1">
<input type="checkbox" name="option2" value="checked value 2">
Then , to group them in the email, you would have to specify how they are printed. Something like this:
PHP: Select all

$body "Group 1:
$checkbox1, $checkbox2, etc...
\n
Group 2:
$checkbox3, $checkbox4, etc..."
;

//Then send the email
mail("my.email@domain.com""Custom Subject"$body"Custom 'From' Field"); 
That's the basic set up...

Cheers
Last Blog Entry: Windows Vista vs. Mac Leopard (Nov 4th, 2007)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #3  
Old Dec 9th, 2007, 17:26
Junior Member
Join Date: Nov 2007
Location: Oregon
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Form to email script with checkboxes

Wonderful -- thank you so much!

I'm sorry if this is a foolish question, but can I assume that when I group the checkboxes like this, only the "checked" boxes will be posted?

Or do I need to add an "if" statement to only post the boxes selected by the viewer?

Again, sorry if that should be obvious. I think maybe I was making this harder than it needed to be.

Thanks!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #4  
Old Dec 9th, 2007, 17:59
Highly Reputable Member
Join Date: Sep 2007
Age: 15
Posts: 717
Blog Entries: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Form to email script with checkboxes

Checkboxes will only be emailed if they're checked. No "if" statement required!
Last Blog Entry: Windows Vista vs. Mac Leopard (Nov 4th, 2007)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #5  
Old Dec 10th, 2007, 03:54
Junior Member
Join Date: Nov 2007
Location: Oregon
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Form to email script with checkboxes

Yeah! Thanks so much!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Saving values from checkboxes into MySql karinne PHP Forum 7 Jan 26th, 2008 16:58
[SOLVED] sending email once form submitted Emzi PHP Forum 5 Nov 21st, 2007 14:25
[SOLVED] Form Submit To Email longstand PHP Forum 17 Nov 13th, 2007 13:16
[SOLVED] Email Submit Form Problem, The tutorial From The Php Forum longstand PHP Forum 3 Nov 12th, 2007 20:06
[SOLVED] Form to email with checkbox itsdesign PHP Forum 4 Oct 29th, 2007 00:57


All times are GMT. The time now is 06:01.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42