ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Contact form not working

April 30, 2008 4:08am

Subscribe [1]
  • #1 / Apr 30, 2008 4:08am

    geertdeg

    4 posts

    I don’t know what I’m doing wrong, but my contact form doesn’t send all the fields properly. I receive the messages only with the “message” field. The other fields disappear. Does anybody know what’s going wrong here? Here’s my contact template code:

    {exp:email:contact_form user_recipients="false" recipients="[email protected]" charset="utf-8" return="{homepage}|Home Page"}
    <input class="fmtext" type="hidden" name="subject" id="subject" value="Message from website" />
    <label for="name">Name</label><input class="fmtext" type="text" name="name" id="name" />
    <label for="address">Address</label><input class="fmtext" type="text" name="address" id="address" />
    <label for="city">City</label><input class="fmtext" type="text" name="city" id="city" />
    <label for="from">From</label><input class="fmtext" type="text" name="from" id="from" />
    <label for="phone">Phone</label><input class="fmtext" type="text" name="phone" id="phone" />
    <label for="message">Message</label>
    <textarea class="fmtextarea" name="message" cols="20" rows="6" id="message"></textarea>
    
    
    {if captcha}
    Please enter the word you see in the image below:
    {captcha}
    
    <input type="text" name="captcha" value="" maxlength="20" />
    {/if}
    <input name="submit" type='submit' value='Send' />
    
    {/exp:email:contact_form}
  • #2 / Apr 30, 2008 10:21am

    Robin Sowell

    13255 posts

    The contact form has a specific list of fields that can be used- anything beyond those fields will be dropped.  Check the docs for details, but in brief, the only ones that will work are:

      *  captcha
      * from
      * message
      * name
      * required
      * subject
      * to

    So- if you want to include city, adress, etc, you’ve got two options.
    1.  The message can be an array- so name those fields message[] a la:

    <label for="phone">Phone</label><input class="fmtext" type="text" name="message[]" id="phone" />
    <label for="message">Message</label>
    <textarea class="fmtextarea" name="message[]" cols="20" rows="6" id="message"></textarea>
    
    

    This works- I’ve done it before, even sticking blank hidden fields in there to add some space to the message.

    2.  Check out Solspace’s freeform module- third part, free, very nice form module.  I tend to install it SOP on any new install.  Still use the contact form in some cases, but for complex bits, I’ll switch to freeform.  I’ve even tied it into payment processes as a poor man’s shopping cart, as it stores the info in the db.

    Think one of those will do the trick for you?

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases