Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New to the CF scene
    Join Date
    Jun 2010
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Need help with one part of PHP E-mail Form

    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
    PHP Code:
    <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">Doesnt 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
    PHP Code:
    $qualiy $_POST['quality[]']; 
    Second snippet from the php file that processes the form data, this is for the body of the e-mail
    PHP Code:
    Qualitys Seeking$quality[]

    Any help will be greatly appreciated! Thank you very much in advance.
    Last edited by INeedAGig; 06-27-2010 at 10:05 PM.

  • #2
    Senior Coder
    Join Date
    Jun 2008
    Location
    New Jersey
    Posts
    2,542
    Thanks
    45
    Thanked 259 Times in 256 Posts
    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
    Code:
    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.

  • #3
    New to the CF scene
    Join Date
    Jun 2010
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I will try that. It is a multiple choice question, that's why I am using the checkboxes.

  • #4
    Senior Coder
    Join Date
    Jun 2008
    Location
    New Jersey
    Posts
    2,542
    Thanks
    45
    Thanked 259 Times in 256 Posts
    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.

  • #5
    New to the CF scene
    Join Date
    Jun 2010
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.

  • #6
    Senior Coder
    Join Date
    Jun 2008
    Location
    New Jersey
    Posts
    2,542
    Thanks
    45
    Thanked 259 Times in 256 Posts
    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.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •