Log in Sign Up

Forms

MagicEdit allows you to create web forms and store the data on the server or send it via email. Of course all of the settings are available to you, the web designer, right from the HTML. MagicEdit takes care of setting up the form so that the proper action is taken. Best of all, there's no scripting or programming required, and if you use the email option, the email addresses used are never exposed to spammers spidering the HTML.

Basic Email Form

Suppose you wanted to create a basic "Contact Us" form on your website. This is probably the most common use of forms on the web. Normally, you'd have to not only build the form, but you'd have to do some scripting or use some specific server-side configuration to make it work. MagicEdit will take care of the server-side stuff too, but you just need to tell it a couple of basic things in order for it to do its job.

In this case, we'll just pop off an email whenever anyone submits the contact form. Here's what our HTML could look like:

<form me_email="me@mydomain.com">

  <label for="name">Name</label>
  <input type="text" id="name" name="name" />
  
  <label for="phone">Phone Number</label>
  <input type="text" id="phone" name="phone" />

  <label for="email">Email</label>
  <input type="text" id="email" name="email" />

  <label>Your Message</label>
  <textarea name="comments" rows="5"></textarea>

   <input type="submit" value="Send Form" />

</form>

That is the most basic use of the MagicEdit forms. It will simply generate and send an email to "me@mydomain.com" (or whatever you specify). The email will be comprised of a table of name/value pairs: the name of each field in the form, alphabetically sorted, with its associated value as input by the user. Other email options for the form tag include inserting a "from" address, a subject, and a page visitors will be directed to after the form submits. An example of a form tag with all these options may look like this:

<form 
     me_email="me@mydomain.com" 
     me_from="contact@mydomain.com" 
     me_subject="An email from your website!" 
     me_page="thankyou.html">

In this case, you would receive an email to your me@mydomain.com inbox. The email would appear to be sent from the contact@mydomain.com address and the subject line would read "An email from your website!" After the visitor submits the form, they would land on the thankyou.html page.

Note: the MagicEdit engine will automatically remove the email addresses and other MagicEdit attributes before sending the form to the browser. It will create a special action on the server side automatically to take care of all the magic. Just like all the other MagicEdit tags, all the "magic" is removed from the page source on the server before sending it to the web browser.

NEW FEATURE: Content managers can now update how the form behaves from their web browser. Simply click on the edit button that appears at the bottom of each form and fill out the appropriate values in the panel that pops up.

CSV Files

Rather than receiving form data through email, you may want to store the data in a CSV (Comma Separated Value) file on the server. This file will be a collection of all data from each form submission, and the file will be saved as text with fields separated by commas. This method is convenient because all the data will be in one place, rather than scattered throughout your mail folders. To use this option instead of email, all you have to do is replace the me_email option with me_csv, like so:

<form me_csv="fileName.csv">

The default path for the CSV file is the root of your site (the parent of your "pages" folder where your HTML lives), and is therefore not publicly accessible. Just use FTP to retrieve the file.

If the CSV file doesn't exist, MagicEdit will write a title row of all the names of the fields in the form in alphabetical order. Subsequent rows are just the values of each form field as submitted on the page. If you change the form by adding new fields or renaming existing ones and MagicEdit sees that there is a file already there, it will NOT rewrite the title row. So if you change the form it is best to delete or rename the old CSV file so you aren't confused by columns with inconsistent data.

Of course, you can use all the same form fields for your CSV file that you can for the email. And, if you so choose, you can always use both email and the CSV!

Required Form Elements

In order for form submission to work, there are a few required elements. You must use either me_csv or me_email. So if you are sending email with your form, then you must use the me_email option. Similarly, forms that send data to CSV files require the me_csv option. Both me_email and me_csv require a value (such as me_email="email@mydomain.com" or me_csv="myCSV.csv").

Optional Form Elements

While not required, me_from and me_subject will make your email submissions look better. Use me_from to specify the name that the email will appear to come from (preferably something like me_from="contact@mydomain.com") and me_subject to define a subject for all form-submitted emails.

You can also use me_page to define a page that users will be directed to after the form has been successfully submitted, such as a "Thank you for contacting us!" page.

Reply-to Email

In some cases you might want the email that gets sent to the site administrator (the email in the me_email attribute) to come from the person filling the form out. To accomplish this, MagicEdit will automatically override the me_from attribute with the value entered in a field in the form with name="email".

This way you can simply reply to the email that comes from the site and be sure that the response will go straight back to the person who submitted the form. Note that if a valid email is not entered in the "email" field the system will default back to the value set in the me_from attribute.

Try MagicEdit today!

Sign Up for free Demo
Scroll to Top