We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 661
    • 33 Posts
    I wasn’t sure whether to place this here or in the snippet forum, so please feel free to move it. wink

    I know there’s a contact form snippet that comes with MODx upon installing. However, I’d like to know how I can create my own PHP form (snippet). I did find a thread with a somewhat detailed answer but I was still lost. (It probably doesn’t help that I’m not *really* a programmer.) I guess I’d just like a quick step-by-step, or some basic guidelines/rules.

    I apologize for the vagueness - I’ve been staring at code for way too long today. smiley
    • If you want to email the form results, you can’t beat eform:

      http://modxcms.com/forums/index.php/topic,2122.msg14915.html#msg14915

      I don’t use the old contact form snippet any more.

      http://www.phpusers.org/contact.html

      Here’s the snippet call:
      [!eForm? 
      &formid=`ContactForm` 
      &to=`[email protected]` 
      &tpl=`ContactForm` 
      &report=`ContactReport` 
      &subject=`PHP Users Group Contact`
      &format=`name:Name:string:1,email:Email:email:1,message:Message:html:1`!]


      The most important thing is that in your form template (the ContactForm template chunk) you must have a hidden input field named formid, and the value is the same as specified in the &formid option (it can be whatever you want):
      <input name="formid" type="hidden" value="ContactForm"/>


      For emailing the form data, you need two chunks, &tpl for the form itself, and &report, which formats the data nicely for the email message. You use placeholders for the various data fields in the report template chunk.

      The snippet uses the phpMailer class library for sending mail, which makes for very flexible use. As it is written, it only uses the php mail() function. I’m considering adding a few more snippet option arguments to allow for SMTP mailing without having to hack the snippet.
        Studying MODX in the desert - http://sottwell.com
        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
        Join the Slack Community - http://modx.org
        • 661
        • 33 Posts
        Thanks for the tip! I’ll look into it.
          • 4273
          • 356 Posts
          can you include your chunk examples of the contact form and contact report form ?

            SMF Bookmark Mod - check it out
            http://mods.simplemachines.org/index.php?mod=350
            • 7455
            • 2,204 Posts
            Quote from: bugsmi0 at Jun 03, 2006, 05:34 PM

            can you include your chunk examples of the contact form and contact report form ?



            If you would read all the post in the eForm section than you would see that I posted a fully working example on how to use this great snippet, Including 2 chunks and the snippet call.

            Dimmy
              follow me on twitter: @dimmy01
              • 661
              • 33 Posts
              Quote from: Dimmy at Jun 04, 2006, 02:48 PM

              Quote from: bugsmi0 at Jun 03, 2006, 05:34 PM

              can you include your chunk examples of the contact form and contact report form ?



              If you would read all the post in the eForm section than you would see that I posted a fully working example on how to use this great snippet, Including 2 chunks and the snippet call.

              Dimmy

              I second that, Dimmy. Though I admit, I had to read it a couple times to make sure I got it. Once I did though, everything started working wonderfully!