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.

For further questions, or if you need help, please open a support ticket from your HostPapa Dashboard. Follow this link to learn how: https://www.hostpapa.com/knowledgebase/hostpapa-dashboard-how-to-open-a-support-ticket/

This article is also available in: French Spanish

Was this article helpful?

  • Was this article helpful ?

  • yes   no

Related Articles