How To E-Mail Form Data, PHP formmail
Freeola Internet Get Dotted Domains Blog Guides Chat
How To E-Mail Form Data, PHP formmail
Menu

Freeola Guides


Creating a Contact Form For Your Website

By Freeola Support on 14th July, 2016 | 9 Comment(s) | 3 out of 3 people found this article useful.

Welcome to the Freeola Internet customer support pages. This guide is designed to help with creating a PHP formmail script for your website. For more internet help topics please visit our main Support Page.

 

Freeola now offers a PHP form mail script for customers to use, this script will allow the contents of any form which you create, no matter how many fields you set up, to be submitted to your Freeola e-mail account.

 

Freeola can provide you with a basic form to use or you can create your own.

 

Click here to view the form code

 

The following instructions assume a working knowledge of how to create web pages, web forms and general FTP/uploading issues.

 

The Form_To_Mail Script

 

Once you have created your form you will need to set the action to connect to the form mail script. Open your form in a text editor such as Notepad on a Windows PC or BBEdit on a Macintosh. If for example your domain name is tomhoy.com the action will look like this:.

 

<form method="post" action="http://tomhoy.com/cgi-bin/form_to_mail.php">

 

If you are using a Freeola500 address such as bob.spursfans.co.uk, the action will look like this:

 

<form method="post" action="http://www.bob.spursfans.co.uk/cgi-bin/form_to_mail.php">

 

Recipients

 

Next you will need to set the recipient e-mail address; for anti-spamming reasons this must be an e-mail address hosted on the Freeola servers such as any Freeola500 e-mail address or any e-mail address which you have created on your domain name. If for example the address you wish to receive the e-mail on is [email protected], the recipient tag will look like this:

 

<input type="hidden" name="recipient" value="[email protected]">

 

From


You must also set the from field; this will be reflected in the From: field in your mail client, i.e. the sender of the email. So if you have more than one form you can easily see which is which.

 

This must be set to a valid Freeola hosted e-mail address.

 

<input type="hidden" name="from" value="[email protected]">

 

Required Fields


You can require certain fields in your form to be filled in before the results will get e-mailed to the recipient. Let's say you have a field called email_address and you don't want the form to send you an e-mail unless the viewer has filled in this section of the form. Enter the following code in the form and the form will return an error informing the viewer to fill in this section:

 

<input type="hidden" name="require" value="email_address">

 

You can add more than one required field by separating them with a comma:

 

<input type="hidden" name="require" value="email_address,name">

 

Redirecting


Once the viewer has filled in the form and sent the e-mail, you can redirect the viewer to a thank you page. If you created a thank you page called thank_you.html, you can redirect the viewer by adding the following code to your form:

 

<input type="hidden" name="success_redirect" value="http://yourdomain.com/thank_you.html">

Please Note

You will be required to enter the full URL of the page in question in order for this step to work correctly.

 

Extra Options for Users of the Freeola Formmail Script

 

We have added some new options to the Freeola provided script. These options will allow you to personalise the script and obtain more information about which users have used your form. Your existing scripts should continue to run without alteration, however if you wish you can selectively add in the new options.

 

Spam Prevention via a Captcha Image

 

Within your form you now have the option to specify that you want a verification page displayed before the email is sent, this will ask the user submitting the form to enter some numbers and letters as displayed on the screen before the submission will go through correctly. This is useful to stop spammers from using scripts to automatically send large volumes of email. This is also known as a PHP Captcha Image and is widely recognised as being one of the most effective ways of preventing unwanted replies from this form.

 

Verification Image

 

To include this in your form you will need to add the following to your form section.

 

<input type="hidden" name="captcha" value="yes">

 

This will add a screen similar to the screenshot above which will not allow the person using the form to submit it without specifying the correct details.

 

User Agent Details

 

The next new option is the ability for the server to send user agent details with the email that is sent. This can be useful for finding more information about the users who are using the script, including information such as the IP address of the machine visiting the page, the Operating System (OS) they are using as well as which web browser they are using to view your web page. To enable this, simply include the information below in your form, and the additional information will be included with the email that is sent.

 

<input type="hidden" name="env_report" value="yes">

 

Further Customization

 

The next option allows you to further customise what a visitor to your site will see when they have not entered data in all the required fields. Include the information below in your form, and change the http://www.mywebsite.com/missing_fields.html to be the URL of the page you have created. Please note that unless you have included the required fields option from above this will have no effect.

 

<input type="hidden" name="missing_fields_redirect" value="http://www.mywebsite.com/missing_fields.html">

 

The last of the new options allows you to specify a webpage for the visitor to see if for some reason the mail is not able to be sent. As before, change the http://www.mywebsite.com/missing_fields.html to be the URL of the page you have uploaded, and include the result in your form section.

 

<input type="hidden" name="fail_redirect" value="http://www.mywebsite.com/email_could_not_be_sent.html">

Did you find this article helpful?

Yes | No


Article Comments (9)
Add your comment:

Comments are limited to 750 characters, you have 750 remaining.


Avatar
jdm4saramoon commented on 23rd August, 2011:
I was going to complain that this code does not work - ie: nothing was arriving in my email box - but I just found my test comments in my JUNK box!! - Something to be aware of! John.
Avatar
Hunny Pot commented on 29th June, 2012:
great info but how do you upload onto the web page? will be reading other pages to find out :)
Avatar
Butch [staff] commented on 3rd July, 2012:
Hello Hunny,

We provide a series of guides on uploading files to the Freeola webservers which can be seen by clicking the 'Webspace & FTP Guides' link at the top of this page.

If you are after some general advice on uploading files, including Freeola hosting packages and methods of uploading, then I can recommend reading through our 'General Webspace and Hosting' guide, which can be found by visiting http://freeola.com/support/webspace-ftp-guide.html.

If you would like any further assistance in using any Freeola hosting service, please contact our helpful Support Team by calling 0871 210 9977 or via our online system found at https://secure.freeola.com/support/request/.
Avatar
Scorpion II commented on 13th February, 2013:
Is there any way of integrating the captcha into the form rather than opening a separate page after the form is sbmitted?
Avatar
Butch [staff] commented on 14th February, 2013:
Hi Martyn,

Unfortunately the captcha details above will only work on a separate page. If you are looking to have such security measures on the same page as your contact form, and you have the scripting knowledge to use it, Google's 're-captcha' form should suit your needs.

A simple internet search should take you to the code, and instructions on how to implement it.
Avatar
Drummer Sam commented on 4th August, 2013:
How do I get the form to send to multiple email addresses please?
Avatar
Butch [staff] commented on 5th August, 2013:
Hi Sam,

For spam and security reasons we do not recommend sending contact forms to more than one address using this script. If you must have these messages sent to more than one account, I would advise you set forwarding on the account itself, rather than through this form.

This can be done through your MyFreeola account.
Avatar
Salisbury Windows commented on 13th December, 2016:
You say - Once the viewer has filled in the form and sent the e-mail, you can redirect the viewer to a thank you page. If you created a thank you page called thank_you.html, you can redirect the viewer by adding the following code to your form: But where on the form am i meant to add this? there are no settings available on the form
Avatar
Butch [staff] commented on 14th December, 2016:
Hello,

Details of which code to add to your custom form to redirect visitors to a 'Thank You' page can be found under the 'Redirecting' heading above.

Simply add this code - with your chosen URL replacing the example one given - within the form script on your page to direct those that complete your form to whichever page you wish.

Freeola is a UK internet service provider offering the best value and extensive free services. Please compare our domain name registration prices or check out our UK high speed internet access. If you are in business please see examples of our free hosting at Freeola.com/customer-sites.

Safe and Secure Payment

Livechat - loading