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.

email contact form questions

January 20, 2011 12:24am

Subscribe [3]
  • #1 / Jan 20, 2011 12:24am

    roryrabbitfield

    320 posts

    I am using the email contact form as described on this page:
    http://ellislab.com/expressionengine/user-guide/modules/email/contact_form.html

    My actual form is here:
    http://bit.ly/gyXlIg

    I am confused. Am I allowed to create fields other than name, subject, message? You see I have a dropdown select, in addition to the standard fields. How do I get the input for the dropdown to show up in the email the system generates? Is this possible with the email contact form? Or must I use something else to do this?

    Here’s my code for the form:

    {exp:email:contact_form user_recipients="false" recipients="[email protected]" charset="utf-8" redirect="5" return="http://mydomain.com/thanks/"}
    <div id="contact_form">
    
    
    <label for="name"><span class="asterisk">* </span>Name:</label>
    
    <input type="text" id="name" name="name" size="32" maxlength="100" value="" /></p>
    
    <label for="from"><span class="asterisk">* </span>Email:</label>
    
    <input type="text" id="from" name="from" size="32" maxlength="100" value="" /></p>
    
    <label for="subject"><span class="asterisk">* </span>Subject:</label>
    
    <input type="text" id="subject" name="subject" size="32" value="" /></p>
    
    <label for="howheard"><span class="asterisk">* </span>How did you hear about us?</label>
    
    <select name="howheard" name="message[]">
    <option value="fiat" selected="selected">Please Choose One:</option>
    <option value="colleage_business_associate">Colleague or Business Associate</option>
    <option value="news_article">News Article/News Release</option>
    <option value="internet_search">Internet Search</option>
    <option value="advertisement">Advertisement</option>
    <option value="event">Event</option>
    <option value="personal_meeting">Personal Meeting</option>
    <option value="other">Other (enter in field below)</option>
    </select>
    
    <label for="subject">If other (from above), please specify:</label>
    
    <input type="text" id="other_specify" name="message[]" size="32" value="" /></p>
    
    <label for="message"><span class="asterisk">* </span>Message:</label>
    
    
    <textarea id="message" name="message[]" rows="10" cols="70"></textarea>
    
    <input name="submit" type='submit' value='Submit' /></p>
    
    </div>
    {/exp:email:contact_form}
  • #2 / Jan 20, 2011 8:15am

    Paul Stone

    97 posts

    Hi,

    You can only use those fields mentioned in the user guide page you linked to, i.e.:

    captcha
    from
    message
    name
    required
    subject
    to

    To ‘fake’ extra fields you have to get creative with the message field (you pass multiple things to it and it adds them all together to send in the email.  For example, look at my contact form here: http://paulstonedesign.com/contact

    The code that makes that up is shown below - all of the lines with lots of - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -‘s in are just to help with the email format that comes through, you don’t need them at all:

    {exp:email:contact_form user_recipients="false" recipients="[EMAILGOESHERE]" charset="utf-8" return="{path=contact/thankyou}"}
    
    <fieldset>
    <legend>Your details</legend>
    
    <label for="name">Your Name:</label>
    
    <input type="text" id="name" name="name" size="40" value="{member_name}" /></p>
    {!--
    <input type="hidden" name="message[]" value="Name:" />
    <input type="text" id="name" name="message[]" size="40" value="{member_name}" /></p>
    <input type="hidden" name="message[]" value="--------------------------------------------------------------" />
    --}
    <label for="from">Your Email:</label>
    
    <input type="text" id="from" name="from" size="40" maxlength="35" value="{member_email}" /></p>
    
    <label>Your Company:</label>
    
    <input type="hidden" name="message[]" value="Company:" />
    <input type="text" id="company" name="message[]" size="40" maxlength="35" value="" /></p>
    <input type="hidden" name="message[]" value="--------------------------------------------------------------" />
    <label>Your Telephone:</label>
    
    <input type="hidden" name="message[]" value="Telephone:" />
    <input type="text" id="telephone" name="message[]" size="40" maxlength="35" value="" /></p>
    <input type="hidden" name="message[]" value="--------------------------------------------------------------" />
    <label>Your Website (if applicable):</label>
    
    <input type="hidden" name="message[]" value="Website:" />
    <input type="text" id="website" name="message[]" size="40" maxlength="255" value="" /></p>
    <input type="hidden" name="message[]" value="--------------------------------------------------------------" />
    <input type="hidden" id="subject" name="subject" size="40" value="[{site_name}] Enquiry from the website" />
    </fieldset>
    <fieldset>
    <legend>How can I help?</legend>
    <input type="hidden" name="message[]" value="Enquiry:" />
    <textarea id="message" name="message[]" rows="10" cols="40"></textarea>
    <input type="hidden" name="message[]" value="--------------------------------------------------------------" />
    <label>Budget:</label>
    
    <input type="hidden" name="message[]" value="Budget:" />
    <input id="budget" name="message[]" type="text" />
    <input type="hidden" name="message[]" value="--------------------------------------------------------------" />
    
    </fieldset>
    
    {if captcha}
    <fieldset>
    <legend>For security</legend>
    Please enter the word you see in the image below:
    <input type="text" name="captcha" value="" maxlength="20" /></p>
    {captcha}
    </fieldset>
    {/if} 
    <fieldset>
    <legend>Almost done…</legend>
    Thanks for taking the time to fill in this form.  I aim to get back to each enquiry within five working days.  Please now click the button below.
     <input type="submit" class="form-button" name="Submit" value="Send your enquiry" /></p>
    </fieldset>
    {/exp:email:contact_form}

    A popular add-on to help create contact forms is this one from Solspace: http://www.solspace.com/software/detail/freeform/

    Hope that helps!

    Paul.

  • #3 / Jan 20, 2011 8:23am

    Paul Stone

    97 posts

    Here’s how my form comes through by email:

    Company:
    Test company
    --------------------------------------------------------------
    Telephone:
    test telephone
    --------------------------------------------------------------
    Website:
    <a href="http://examples.com">http://examples.com</a>
    --------------------------------------------------------------
    Enquiry:
    This is my enquiry
    --------------------------------------------------------------
    Budget:
    1 billion
    --------------------------------------------------------------
  • #4 / Jan 20, 2011 10:50am

    roryrabbitfield

    320 posts

    Thank you, Paul! That is most helpful. I think I might just go the Freeform route; I used it once before and I don’t know why I didn’t think of it for this project. I really appreciate seeing you code for this; I’m going to dissect it to learn more about what this does since for a very simple form it is so easy to use.
    Rory

  • #5 / Jan 20, 2011 4:54pm

    Ingmar

    29245 posts

    Thanks for the assist, Paul 😊 Please post again as needed.

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

ExpressionEngine News!

#eecms, #events, #releases