Registered users can click here to access more content / Geregistreerde gebruikers kunnen hier klikken om in te loggen.

12ValidateForm

I made 12validateform in two version. 12validateform simple and 12validateform extra. Both can check any html form to see if the specified compulsory fields are not blank. If there are fields blank, the visitor is notified and send back to the form. If all data is correctly filled in 12validateform simple will format the form data into a message and send it to a specified email address. 12validateform extra, will first format a message to send to the visitor who filled in the form. In this message the visitor is asked to confirm the data. Meanwhile his data is saved in a temporary file on your computer. If a confirmationlink in the message to the visitor has been clicked the data is formatted into another message and send to you. The visitor can also cancel his message and you can put a maximum number of days for data to be stored.

What do I need?

The script uses only PHP. Some of the functions used in the script are PHP 4 only. So you'll need at least this version to make it work correctly.

Who can use the script?

Unlike all other content on my site, my plugins and scripts are released under a GNU General Public License. A copy of the full license text is included with your Wordpress distribution and can also be found here. I appreciate it when you let me know if and how you use my script.

Installation?

As there are two variant of the script there are two installation procedures. First the one for the simple version, afterwards the installation procedure for the extra version.

Installation simple version.

Installation is fairly easy. First you'll have to make a form in html. Let's say you called it form.html. To make the scripts work you'll have to make sure that the form tag is set as follows:

<form name="<em>whateveryouwant</em>" method="post" action="12validateform.php">

In the form make make sure you're fields have names that correspond there value. So call the address field address, the phone number field telephone, etc. To determine the field that are compulsory we use hidden fields. For each compulsory field you use the following code.

<input type="hidden" name="compulsory[]" value="<em>nameofcompulsoryfield</em>">

So if the name and the remarks fields have to be compulsory, you'll enter this code:

<input type="hidden" name="compulsory[]" value="name">
<input type="hidden" name="compulsory[]" value="remarks">

When the form page has been made. You make another html page with a thank you. This page will be shown after the visitor has filled in the form. For now we assume you call this file thankyou.html. The last thing you need to do is prepare the script. First rename 12validateform.php.simple to 12validateform.php, so strip the .simple. Open it in a text editor. You only need to change a few variables. What they are is explained in the script. Saved 12validatform.php.

The last thing you need to do is change the file data.txt in the messages folder. In data.txt you write the message you wish to send via email, with the formdata. In this message you can call the values of all fields in your form. Or you can call a list width all values. To call a field value in the message type %<em>nameoffield</em>% to call the list with all values call %formdata%. E.g. to call the name of the person with the value he typed into the name field of your form type %name%. Save the file data.txt.

Upload 12validateform.php form.html, thankyou.html and data.txt to a directory on your server. Make sure data.txt is in a directory called messages, directly under the folder in which 12validateform.php will be. Call form.html in your browser and make a test.

Installation of the extra version.

Also this is not difficult. It's a lot the same as for the simple version, so please read those installation notes first. For the extra version you'll also need to make a form (e.g. form.html) the same way as for the simple version. The only difference is that you need to make a textfield called email. E.g.: <input type="text" name="email"> This field is always compulsory and does not need to be specified with a hidden field as is the case for other compulsory fields. Instead of just the thankyou.html from the simple version you need to create 3 pages:
1. To notify the visitor that a confirmation email has been send (e.g. notice.html)
2. To confirm sending of data after confirmation. (e.g. confirmation.html)
3. To confirm deleting of data after cancellation (e.g. cancellation.html)

After that rename the file 12validateform.php.extra to 12validateform.php and open it in your text editor. Alter the variables on top of the file and save it.

Now alter data.txt as described above. Do the same with confirm.txt. The text of this file is put in the confirmation mail that is send to your visitor. The calling of field values works the same as with data.txt. In confirm.txt are two strings which you should not forget. They are %confirmlink% and %cancellink% and should not be left out. They will be replaced with the link the visitor has to click to confirm or cancel.

Upload 12validateform.php form.html, notice.html, confirmation.html, cancelation.html, data.txt and confirm.txt to your server. Make sure data.txt and confirm.txt are in a directory called messages, directly under the folder in which 12validateform.php will be.

The last thing you need to do for the extra version is to create a directory called data directly under the directory in which 12validateform is put. Make sure that the writing permissions are set correctly (777). You can also upload 12createdatadir.php to the same directory as 12validateform.php and call it in your browser. The data directory will be created for you, Notice: This does not work on all servers!!!.

Call form.html in your browser and make a test.

Download the script

You can download the script as a zip-file. In this zip-file are 7 files:

  • 12validateform.php.simple; script for 12validateform simple
  • 12validateform.php.extra; script for 12validateform extra
  • 12createdatadir; Very little script to install the data directory.
  • form.html: simple example form.
  • messages/data.txt: example for a data message file.
  • messages/confirm.txt: example for a confirm message file.
  • 12readmefirst.txt: text file with a copy of this text.

The current version is 0.4: download 12validateform_v0.4.zip

Problems / Questions / Suggestions / Support?

Sorry, but I do longer give support for this plugin. Development has been dead for 2 years and this page is nothing more than an archive.

What changed?

0.4 Fixed a little bug, so you don't have switch register_globals on. Thanx to Chris Guest.
0.3 Fixed a bug in the datachecking.
0.2 Added the extra version.
0.1 This were it started.