With webRES Custom Pages you can make a form that will send an email, like a contact form or enquiry form.
- Add Custom Page
- Go to Applications > webXG webRES > Custom Page Configuration to create your new form page.
- Click on New Page
- Enter a filename for your new page with the format email_forms/FORMNAME/form.html where FORMNAME is the unique name of your form e.g.
email_forms/my_form/form.html
NOTE: make sure your form name doesn't contain any spaces or special characters.
- Enter an alias for this page FORMNAME.html e.g.
my_form.html
- Click Save Page
Some other example names:
test_form
- Page Name: email_forms/test_form/form.html
- Alias: test_form.html
- URL: www.example.com/test_form.html
vehicle/enquiry
- Page Name: email_forms/vehicle/enquiry/form.html
- Alias:vehicle/enquiry.html
- URL: www.example.com/vehicle/enquiry.html
- Add the html form contents
- Click on the page name you just created
- Click on Edit Source
- Add the code for your form. Do not put the
<&| /mc/box &>
Forms are fun!
&>
- Add Email template
- Go back to Custom Page Configuration like step 1 again to add an email template. Use the format email_forms/FORMNAME/email.html e.g.
email_forms/my_form/email.html
- In the email template you can print variables from the form using the code
<% $input->{FIELDNAME} %>
These variables will be named by the name="" attribute on the form fields. Example:
<% $input->{name} %> has filled out your form.
<% $input->{forms_are_fun} %>
<%args>
$input => {}
%args>
<%flags>
inherit => undef
%flags>
<%attr>
to => 'contact@example.com'
from => 'webmaster@example.com'
cc => 'sales@example.com'
bcc => 'webmaster@example.com'
subject => 'Email from form'
%attr>
- Customise the fields in the attr section with the subject and email addresses to send to.
- Add confirmation page
- The final step is to add a page that will be shown to the user after they submit the form. Use the name format
email_forms/FORMNAME/onsubmit.html
e.g.:
email_forms/my_form/onsubmit.html
-
Click Edit Source as before and enter the code for the confirmation page e.g.
<&| /mc/box &>
Thanks <% $input->{name} %>! An email will be sent.
&>
<%args>
$input => {}
%args>
- Test your form
Your form will be available at your website using the alias you set earlier. e.g.
www.example.com/my_form.html
Note:This facility is only available for a custom, non-tabbed page.