How do I make a PHP contact form? Print

  • Email, PHP, WordPress
  • 215

What is PHP?

PHP usage is common across the Internet. The nature of PHP makes it both easy to use & deploy on existing websites. 
Similar to JavaScript, PHP can be embedded into existing HTML adding a host of extended features. One of differences of PHP over JavaScript is that PHP is ran server side retaining functionality whilst, also obscuring the original code from visitors. 

Why do I need a PHP contact form?

A PHP contact form is both easy to create and integrate into an existing website.
Whilst, PHP contact forms are simple they're very beneficial. Enabling simple communication between yourself and site visitors.

There are a few ways to take advantage of a contact form. If you're currently using WordPress there are many different plugins available. This is the easiest option as you will only need to consider configuration with no need for PHP, or SQL knowledge. And you'll never have to worry about updates! 

How can I create my own PHP contact form?

A good starting point for your PHP form is this article

To get this form to work with our hosting properly you will need to set the "From" address in the code as below:

Where the code says: 
mail($to,$subject,$message,$headers);

You need to add the from address in this format:
mail($to,$subject,$message,$headers,"-f your@email.here");

The address should be one that is configured on your server.

If you're using Plesk with an older version of PHP (5.3 or lower) you will also need to disable PHP safe mode within the control panel.

Important Note

Contact forms are a great tool but if left unsecured they can easily fall victim to attack. Malicious actors such as Spammers can trick a contact form on your site into sending out spam emails. 
At Unlimited web hosting we have a robust spam detection system and we regularly monitor traffic across our services to determine whether it is legitimate. If an account associated with your site is seen to be sending out spam you run the risk of suspension. Therefore, its important that you make efforts to secure your contact form with a CAPTCHA. 

 


Was this answer helpful?

« Back