How to create a PHP contact form for your website

Contact forms are used on websites to allow users to get in touch with site owners and leave a simple message. Using contact forms, rather than simply adding an email address to the website, can protect site owners from receiving spam email.

Here is a simple PHP email form you can place on your website. To use it, do the following:

Download the php_email_form.zip file and extract it to a local folder.

Extracted zip file

Edit the FormToEmail.php file in a text editor like Notepad (Windows) or TextEdit (Mac).

Editing script

Scroll down to the line that reads:

$my_email = "delete these words and put the email address only in here between the quotes";

and replace the text between the quotes with the email address you want the form to be sent to. Save the file with the exact same file name.

Editing the file

Use cPanel File Manager or an FTP client to upload both the FormToEmail.php file and formphp.html to the web root folder of the domain (public_html for the primary domain).

Upload files

Create a link on your website to the formphp.html file.

If you need help with your HostPapa account, please open a support ticket from your dashboard.

Related Articles

This post is also available in: FrançaisEspañol
Get online with our affordable web hosting

Get online with our affordable web hosting

Learn more now
HostPapa Mustache