Web Hosting Knowledge Base
How to create an example contact form?6 min read
In this tutorial, we are going to demonstrate how to set up a working PHP contact form in your AwardSpace web hosting account.
Each contact form consists of two components: the actual form and the PHP mailer script that processes the information and sends an email. Setting up a PHP contact form on a web server is a three-step process:
- Registering an e-mail account;
- Creating an HTML form;
- Creating a PHP script.
Step #1: Registering an Email Address
The very first step is to create an e-mail account on your server. Our mail server requires authentication in order to send emails out. Therefore, by using one of the emails that exist in your Hosting Control Panel as a sender (from address), you will be able to authenticate yourself and the server will be able to deliver the message to the specified recipient address.
Detailed information on how to set up an e-mail address in your AwardSpace account can be found on our How to create an email account? page.
Step #2: Creating an HTML Form
Add a new HTML file to your website’s root directory (e.g. contact.html) and insert the following code into it:
Save the changes you’ve made and proceed to the next step.
Step #3: Creating a PHP Mailer Script
Upload an empty PHP file to your server with the name of mailer.php, and place it next to your contact.html file.
Double-click on the document you’ve uploaded, and copy and paste the below script into it:
Note: Make sure you replace
firstname.lastname@example.org with a valid e-mail address created through our system.
Now that you’ve followed the above instructions, it is time to test your contact form’s functionality.
To see if your contact form is capable of sending messages, open your HTML document in a browser. Fill in the appropriate fields and click Send:
After you submit the information to the server, the mailer.php script will return either a positive or negative response.
If the test is successful, your browser will display a Your message has been sent successfully! message.
It's Time to Share Your Story.
Get Free Web Hosting. Start a website, and introduce yourself to the world.