Form editor

Forms are quite flexible and handy way to gather infromation from your users: you can create a list of your regular users and send the periodic newsletters, you can create a signup form for a calendar event (RSVP) or basically any type of event and you can create even a poll.

Of course you may want to send email to the people that filled the form. First of all, you, of course, have to include an email field in the form so that they can give their email to you :-) and after that,  you can send email to the selected people from the Forms/Form data tab.

Creating a form

When creating a form, you need two pages: one page to lay it on, and one page where the form takes the user when s/he presses the Submit form button; the target page or thank-you page. So, have these pages ready when you start creating a form (actually at this phase only the target page needs to exist).

Creating the form should be quite straightforward. Just create enough fields, the information you need to gather, and, in the end, you create also the submit button. There's a reason you need to create also the submit button yourself: you may want to define the text it shows, and, you can add Javascript to it, for example, for validating the form.

Placing the form on your site

Now, click a page on the left pane, ie. start editing a page. You will place the form on this page with the editor tools. When you have the page editor in front of you, find the same icon that represents forms in the top of the page. It looks the same but it is smaller. Click that icon and select the form you just created. On the editor should appear a yellow dotted square which represents the form you added. Save the page and click the view page icon and you should see the form on your site.

Thank-you page

You may want to hide the thank-you page from the navigation menus on your site. To do this, go to the page properties (of the thank-you page) and look for the metadata field named hide_on_web. Set that to 1.

Handling forms in a custom way

You may want to handle your forms in a custom way, like sending an email confirmation when the form is submitted or doing something else on the background. You can handle these cases by adding some PHP code into the thank-you page.

First, you need to set the thank-you page to be a php script, and you will do this in the page properties.

Then it's just about adding the PHP code into the page. Edit the page normally. For example, here's a little script that sends an email notification into the address that the user submitted.

<?
mail($_REQUEST["ndform"]["email"], "Subject here", "Hello!\n\nWe have received your info. We will get back to you in no time.\n\n", "From: Site X <info@sitex.com>");
?>

Here is one important thing that must be right, it is the variable name that holds the email address that the user entered. That variable name depends what was given in the form as the label for the form field. If you label that form field as "Email", the variable name would be $_REQUEST["ndform"]["email"]. That is, the variable name is the lower case name of the label. You can see the variable names in the form data page, when you hover over the headers, and you can also add this little PHP script onto your thank-you page to see them:

<? var_dump($_REQUEST["ndform"]) ?>