LexiConn Knowledgebase

Knowledgebase Home | Favorites Knowledgebase Home | Favorites
Search the Knowledgebase Browse by Category
Using Checkbox Fields in a Formmail.php Form
Article Details

Last Updated
5th of October, 2009

User Opinions (199 votes)
54% thumbs up 45% thumbs down

How would you rate this answer?
Helpful
Not helpful

You can expand your formmail.php forms to use checkbox fields, as long as you follow the proper naming convention for the checkbox fields.

Here is a standard formmail example with a few checkbox fields added:





Where did you hear about us?








Checkbox fields must have the square brackets ([]) after each of their names, otherwise only the value of the last checkbox field will be included in the form results.

Here is the code for this form:

<form action="#" method="post">
    <input type="hidden" name="recipients" value="you@Your_Domain.com">
    <input type="hidden" name="subject" value="Subject of email">
    <input type="hidden" name="good_url" value="http://www.Your_Domain.com/thankyoupage.html">
    <label for="name">Name</label>
        <input type="text" id="name" name="name">
       <br />
       <br />
    <label for="email">Email</label>
        <input type="text" id="email" name="email">
       <br />
       <br />
    <div>Where did you hear about us?</div>
       <hr>
        <input type="checkbox" name="ReferralSource[]" id="newspaper" value="Newspaper" />
            <label for="newspaper">Newspaper Ad</label>
          <br />
        <input type="checkbox" name="ReferralSource[]" id="television" value="Television" />
            <label for="television">Television Ad</label>
          <br />
        <input type="checkbox" name="ReferralSource[]" id="web" value="Website" />
            <label for="web">Web Site</label>
          <br /> 
          <br />
    <label for="comments">Comments</label>
        <br />
    <textarea id="comments" name="comments" cols="40" rows="10"></textarea><br>
    <input type="submit" name="submit" value="Submit">
</form>




Related Articles
Attachments
No attachments were found.

Powered by Interspire Knowledge Manager Knowledgebase Software