5th Step: Configuring config.php - Summarizing configuration

Top  Previous  Next

We have configured our form, thank you page and prepared required email templates. Now in order to make final configurations we have to teach FPP how we would like our form to be processed. To do so we have to edit config.php located in Form Processor Pro installation.

Files placement on web server

Before that, we should place created files to the web server as we will use paths to these files in our config.php file. So, we place contact.html and thank-you.html to the web server's www public folder. Both email template files (email.txt and autoresponder.txt) we place in separate folder under www.

www - public folder of mydomain.com
fpp - folder with installation of Form Processor Pro
attachments
classes
install
lang
plugins
tmp
.htaccess
captcha.img.php
config.php- configuration file
fpp-test.php
index.php
style.css
..
contact - folder with email templates
.htaccess - protect this folder from outside browsing, see tip-suggestion below
email.txt
autoresponder.txt
contact.html - our contact form
thank-you.html - our thank you page
.. - and other web site pages

In our case:
FPP can be accessed through: http://www.mydomain.com/fpp/index.php
Contact form can be accessed through: http://www.mydomain.com/contact.html

 

Tip:
In order to protect your email template files from undesirable browsing through HTTP we suggest you to place them in separate folder and protect this folder from browsing. You can use .htaccess file for this purpose on any Unix/Linux compatible host. Just add/create this file(.htaccess) in the folder with email templates with the following content (you can also copy .htaccess file from “tmp” or “attachments” folder of the Form Processor Pro installation):

<Files *>

  Order allow, deny

  Deny from all

</Files>

You will protect yourself from email harvesting bots by doing this.

On Windows based hosts you can do this by setting correspondent permissions for this folder.

Adding new form to config.php file

Now we have all required files in place and we can edit our config.php

 

Note:
Please, use plain text editor to edit config.php to prevent adding unnecessary lines and symbols.

Sample content for config.php

 

<?php header('Location: index.php'); ?>

/* GLOBAL FPP SETTINGS - BEGIN. THESE SETTINGS ARE APPLIED TO ALL FORMS! */

 

mysql_host = localhost

mysql_user = user_name

mysql_password = password

mysql_db = fpp5

 

smtp_server = localhost

smtp_port = 25;

 

date_format = H:m d/m/y

 

/* GLOBAL FPP SETTINGS - END */

 

/* FORMs' configurations. [form_name] - Declares form name and its settings below. */

 

[some_form]

page = ../form.html

page = ../thank-you.html

required_fields = name (Full Name), email (Contact Email), subject (Subject)

email_fields = email (Contact Email)

autogen_email = info@mydomain.com

First, we have to declare new form in our configuration file. We do this by adding form name in [] brackets as a new line at the end of config.php file or just after global settings section. The form's name is the value used for previously added hidden files. In our case it's “contact_form”.
In our case we have:

[contact_form]

After form's declaration we can put any form settings just after this line.

Defining pages and their order

Ok, now we have to declare all pages that would be used during Form Processor Pro work in a particular order of process. We use “page” setting for this purpose and set full or relative paths to these pages (relative to fpp installation path). If we would like to show thank you page just after successful submission of our one-page contact form we have to put it as second one.
Just like this:

page = ../contact.html
page = ../thank-you.html

 

Note:
You have full control over any server-side script execution on form pages.

If you use relative or absolute path to file (e.g.: "../form/file.html" or "/fpp/form/filename.php") Form Processor Pro will open it as a text file. No scripts (e.g.: PHP, ASP) will be executed on the page.

If you use full URL (e.g.: "http://www.yoursite.com/path/file.html") Form Processor Pro will let webserver execute all server-side scripts on the page, and then will parse the form.
PHP option "allow_url_fopen" must be enabled to allow this behaviour.

Setting up validations

In order to set Full Name, Email and Subject fields as required we need to use “required_fields” validation rule and put all required field names here. See below:
required_fields = name (Full Name), email (Contact Email), subject (Subject)

Please note that phrases in ( and ) brackets are just used in error messages instead of internal field names from HTML. Thus your error messages can be intuitive, user-friendly and you can even use language other than English! As we have already mentioned you can put validation rules as one field per line or write all in one string and separate field names by comma.
Thus:

required_fields = name (Full Name), email (Contact Email), subject (Subject)
and
required_fields = name (Full Name)
required_fields = email (Contact Email)
required_fields = subject (Subject)

Will have the same effect - required form fields: name, email and subject.

In order to restrict only properly formatted emails in email field we will use “email_fields” validation rule, the same way as above:

email_fields = email (Contact Email)

As you can see you can have more than one validation per one field - any amount, actually. But they have to be reasonable of course.

For more information about possible validation rules refer to Field Validations chapter.

Setting up email sending

We would like to send two emails: one for us with form results and another as auto responder for submitter. We have already created these templates and we use them here with “email” action. Just like this:

email = ../contact/email.txt
email = ../contact/autoresponder.txt

For more information about possible actions refer to Actions chapter.

That's all configurations for the config.php file according to our initial requirement to this Contact Form.

After adding all of the above to our config.php we will have the following changes in it:

 

<?php header('Location: index.php'); ?>

/* GLOBAL FPP SETTINGS - BEGIN. THESE SETTINGS APPLY TO ALL FORMS! */

 

mysql_host = localhost

mysql_user = user_name

mysql_password = password

mysql_db = fpp5

 

smtp_server = localhost

smtp_port = 25;

 

date_format = H:m d/m/y

 

/* GLOBAL FPP SETTINGS - END */

 

/* FORMs' configurations. [form_name] - Declares form name and its settings below. */

 

[contact_form]

page = ../contact.html

page = ../thank-you.html

required_fields = name (Full Name), email (Contact Email), subject (Subject)

email_fields = email  (Contact Email)

email = ../contact/email.txt

email = ../contact/autoresponder.txt

 

[some_form]

page = ../form.html

page = ../thank-you.html

required_fields = name (Full Name), email (Contact Email), subject (Subject)

email_fields = email (Contact Email)

autogen_email = info@mydomain.com

That's all! We have finished configuring our first form!