Simple Contact form with PHP

Image for post
Image for post
Simple PHP Contact Form Top Level If Condition Checking for ‘email’ in the $_POST Super Global Variable
<form name="contactform" method="post" action="">
<input type="submit" value="Submit" name='submit'>
$email_to = "youremail@domain.com";$email_subject = "Your email subject line";
Image for post
Image for post
The tale of a very sad function.
// validation expected data exists
if(!isset($_POST['first_name']) ||
!isset($_POST['last_name']) ||
!isset($_POST['email']) ||
!isset($_POST['telephone']) ||
!isset($_POST['comments'])) {
died('We are sorry, but there appears to be a problem with the form you submitted.');}
$first_name = $_POST['first_name']; // required
$last_name = $_POST['last_name']; // required
$email_from = $_POST['email']; // required
$telephone = $_POST['telephone']; // not required
$comments = $_POST['comments']; // required

Written by

Front-end Web Developer. Language lover. Traveler. Dude.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store