FormMailer with Personalized Reply Page


CMSimple itself possesses a contact page possibility. However, this feature has a fixed structure and offers only few input fields. And if the contact mail has been sent, the reply page is pretty meager. There are Formmailers as plugins available as well as a Custom Mailform which offer more possibilities. However, the best way to allow contacts with customers or website visitors is the own designed formmailer in conjunction with a customized reply page.

This description serves as an extended explanation of the topic which has been published at CMSimple and MySQL. The difference is just the missing MySQL link. Otherwise, it is the same procedure. advanced_form


You want to generate an html form which sends the visitor's input to your Email address. After mailing the visitor receives a replay page which turns up all the data he put in (and maybe some more information you want to supply him with).


1) Form Generation
You generate an html form like:

<html><head><title>My Form - created with phpFormGenerator</title></head>
<font face='arial' size=2><b>All fields marked with a * are required:<br />
<form enctype='multipart/form-data' action='./?answer' method='post'>
<table width='50%' border=0 valign='top'>
<tr><td> Name<font color='#ff0000'>*</font></td>
<td><input type=text name='Name' size=30></td></tr>
<tr><td> Street<font color='#ff0000'>*</font></td>
<td><input type=text name='Street' size=30></td></tr>
<tr><td> City<font color='#ff0000'>*</font></td>
<td><input type=text name='City' size=30></td></tr>
<tr><td> ZIP<font color='#ff0000'>*</font></td>
<td><input type=text name='ZIP' size=30></td></tr>
<tr><td> Email<font color='#ff0000'>*</font></td>
<td><input type=text name='Email' size=30></td></tr>
<tr><td valign="top"> Comment<font color='#ff0000'>*</font></td>
<td><textarea name='Comment' rows=5 cols=40></textarea></td></tr>
<input type='submit' value='Submit Form'> 
<input type=reset value='Clear Form'></form>

Form pageHereby, it is important that you direct the action of the form to an empty, hidden CMSimple page which - in this example - is called “answer”. Here, the reply will be rendered. But we will come to it later.

<form enctype='multipart/form-data' action='./?answer' method='post'> . . . . 

For this task, let's save the file as “form.html” in a subdirectory of a fresh CMSimple installation called “TS_comment”. The CMSimple folder structure would look now like:


2) PHP file
customized Reply pageNext, you generate the PHP file which is supposed to carry over the variables that contain the visitor's input data and process them. Maybe, the easiest way to create such a PHP file from scratch is using the phpFormGenerator which you will find at Sourceforge. You save this newly created file as “process.php” in the subdirectory “TS_comment”.

3) Template Changes
In order to pass the variables containing the visitor's data to the PHP file which processes the data, sends an Email to the owner of the website, and makes the input data visible again for the visitor the template has to be changed.
In our example we take the CMSimple “default” template. There it says in the template.htm file:

<?php echo editmenu();?>
<?php echo content();?>
<?php echo submenu();?>

Below <?php echo content();?> we add an additional line which then looks altogether like.

<?php echo editmenu();?>
<?php echo content();?>
<?php if($u[$s]=='answer'){include($pth['folder']['base'].'/TS_comment/process.php');} ?>
<?php echo submenu();?>

The job of the new line is the followinig: The “form.html” file directs the action of the form to the empty, hidden CMSimple page “answer” (we will come next to it). However, this empty page cannot do very much by its own. Therefore, the “process.php” file - stored in the “TS_comment” subdirectory - is called to help. This PHP file will catch the variables, process them, and return them as output in the yet hidden page “answer”.

4) CMSimple Pages
That means, we need two CMSimple pages. One page which holds the form, the other one which renders the reply.
First, let's generate the form page. Create it with a heading called “Contact”. Below the heading add the script:

#CMSimple $output.= geturl('./TS_comment/form.html');#

Save it. It calls the externally stored formmailer.

Next, you need the empty hidden page. Generate it using “answer” as H1, H2 or H3 headding (at the end of your content file) and add the CMSimple script to hide:

<h1 style = "display:none;">answer</h1> #cmsimple hide#

The CSS statement “display:none” is added in order to hide the “answer” headding when the reply page is rendered. The hidden page should be placed at the end of your content to not intermingle with the “Locator” function (see CMSimple Installation manual). It can be an H1, H2 or an H3 header page.

Now, we should be set up with our personalized reply page. In case parts of the description are still incomprehensible, a download with an example is available which offers all the changes that have been described.


This download file contains three folders, a “content” folder with a prepared “content.htm” file, a “template” folder with the modified “default” template, and the new “TS_comment” folder holding the “form.html” file as well as two PHP files required for the reply page. All files can be used immediately as they are. You should copy them to a fresh CMSimple installation to test them.

In order to send mail to the website's owner, you should change the mail address in line 31 of the file ”./TS_comment/process.php”, where it say: “”.

The contact form sheet is stuffed with “Dreamweaver's” Javascript error checking. In addition “process.php” uses PHP driven error checking for rejecting inputs with empty required fields.


tips_and_tricks/personalized_reply_page.txt · Last modified: 2009/12/03 18:56 (external edit)
Webdesign: NMuD = chi`s home Creative Commons License Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0