Have you ever wanted to create a PHP mail form on your website? Even if you have no idea what you’re doing, this guide will help you get your form up and running in no time.
You’re going to need to work from 4 files:
- HTML file, which holds the actual form.
- PHP file, which will compile the form contents, validate and actually send the email.
- Another HTML file, which will serve as a thank you page when the form submission is completed successfully.
We are going to be creating a simple form, featuring a First Name, Last Name, Email, Phone and Message inputs. We will also be directing the post of the form to our PHP file, sendmail.php, which will take care of the rest of the processing.
Next, we will be creating the PHP sendmail.php script.
Lastly, the thank you page for successful submission of the form.
That’s it! Feel free to modify this script as you see necessary.