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 Ecenica Hosting.
Example PHP contact form code
- Copy and paste the code from our link below into a new contact.php file in your Ecenica web space, under the 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 Ecenica 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.