The following is an example of a basic form-to-email script using PHP.
- Web space with PHP support.
- A valid email address to send the emails from. This must an active account hosted with DomainsFoundry Hosting.
Example PHP contact form code
- Copy and paste the code from our link below into a new contact.php file in your DomainsFoundry web space, under your public_html folder.
- Edit and change the $to = “firstname.lastname@example.org”; line to the email address you want to receive your contact form messages at.
- Change the $from = “email@example.com”; line to an email address on your DomainsFoundry hosting account.
- Change the subject line ‘$subject = “An example of a simple Contact Form using PHP mail() function”;’ to your preferred subject.
- Save your contact.php file
- Open your web browser and visit at https://www.example.com/contact.php, replacing example.com with your own domain.