...

View Full Version : Need help with one part of PHP E-mail Form



INeedAGig
06-27-2010, 09:02 PM
Hi there, I am having one little problem with part of my e-mail form. Everything is working fine when the form is processed and sent to my e-mail, but there is one part of the form where I have a question and multiple answers can be selected via checkboxes. But, when the form is processed and sent to my e-mail it is not displaying any of the checkbox options. I'm not sure what to do to have it display the checkboxes that were selected in the e-mail. I have provided a couple snippets of code from where I am having the problem.


This is a section from the actual php page of the form


<div id="form_qualitys">
<input type="checkbox" name="quality[]" id="quality[]" value="Attractive">Attractive</input>
<input type="checkbox" name="quality[]" id="quality[]" value="Finacially Secure">Financially Secure</input>
<input type="checkbox" name="quality[]" id="quality[]" value="Hard Worker">Hard Worker</input>
<input type="checkbox" name="quality[]" id="quality[]" value="Sense of Humor">Sense of Humor</input>
</div>
<div id="form_qualitys_2">
<input type="checkbox" name="quality[]" id="quality[]" value="Laid Back">Laid Back</input>
<input type="checkbox" name="quality[]" id="quality[]" value="Organized">Organized</input>
<input type="checkbox" name="quality[]" id="quality[]" value="Outgoing">Outgoing</input>
<input type="checkbox" name="quality[]" id="quality[]" value="Likes Sporting Events">Likes Sporting Events</input>
</div>
<div id="form_qualitys_3">
<input type="checkbox" name="quality[]" id="quality[]" value="Doesnt Like Sports">Doesn't Like Sports</input>
<input type="checkbox" name="quality[]" id="quality[]" value="Social">Social</input>
<input type="checkbox" name="quality[]" id="quality[]" value="Career Oriented">Career Oriented</input>
<input type="checkbox" name="quality[]" id="quality[]" value="Family Oriented">Family Oriented</input>
</div>
<div id="form_qualitys_4">
<input type="checkbox" name="quality[]" id="quality[]" value="Easy Going">Easy Going</input>
<input type="checkbox" name="quality[]" id="quality[]" value="Religious">Religious</input>
<input type="checkbox" name="quality[]" id="quality[]" value="Spiritual">Spiritual</input>
<input type="checkbox" name="quality[]" id="quality[]" value="Smart">Smart</input>
</div>


First snippet from the php file that processes the form data


$qualiy = $_POST['quality[]'];


Second snippet from the php file that processes the form data, this is for the body of the e-mail


Quality's Seeking: $quality[]
\n


Any help will be greatly appreciated! Thank you very much in advance.

Keleth
06-27-2010, 09:06 PM
Uh... first, everything having the same name won't give you any meaning results. Second, everything having the same ID is wrong. IDs should be unique.

When you put

Quality's Seeking: $quality[] \n

PHP thinks you're trying to do something with an array... plus, you defined "$quality"... not "$quality[]". Honestly, why use brackets in the name anyway? I donno if it works or not, but given what brackets mean in PHP, its poor design imo. Get rid of that and give each checkbox a unique name to get any meaningful results. If you want it so the user can only pick one choice (which seems to be the case), you want a radio button, not a checkbox.

INeedAGig
06-27-2010, 09:18 PM
I will try that. It is a multiple choice question, that's why I am using the checkboxes.

Keleth
06-27-2010, 09:24 PM
Well, if you want back multiple results, you need to be able to tell different results. By repeating the same name over and over, you won't actually get back any unique results.

INeedAGig
06-27-2010, 09:32 PM
Okay, I got it fixed. Thanks Keleth.

Yeah, the only reason I gave them the same name for that question is because of what I had read elsewhere for having multiple checkbox answers sent via e-mail.

Keleth
06-27-2010, 09:35 PM
I mean, its possible there's some framework or other code that lets you, but as far as I know, plain HTML and PHP can't handle that.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum