contact engine

hello, i am new to working with php and i am trying to teach myself some basic functions. i have a contact engine file and i only want an error if the email is field is empty but currently get an error if all the forms are not completed. i changed the ‘if’ line to only show email but it did not change anything. can someone look at this code and help me understand what i am doing incorrectly?


$name = $_REQUEST['Name'] ;

$email = $_REQUEST['Email'] ;

$phone = $_REQUEST['Phone'] ;

$contact = $_REQUEST['Contact'] ;

$inquiry = $_REQUEST['Inquiry'] ;

$message = "Name: $name \n

E-mail: $email \n

Phone: $phone \n

Best Time to Contact: $contact \n

Inquiry: \n


if (empty($email)) {

header( "Location: error.php" );


else {

mail( "[email protected]", "Information Inquiry",

  $message, "From: $email" );

header( "Location: thankyou.php" );




try something like

<?php $name = $_POST['Name'] ; $phone = $_POST['Phone'] ; $contact = $_POST['Contact'] ; $inquiry = $_POST['Inquiry'] ; $message = "Name: $name \n E-mail: $email \n Phone: $phone \n Best Time to Contact: $contact \n Inquiry: \n $inquiry"; if(empty($_POST['Email'])) { header("Location: error.php"); } else { $email = $_POST['Email']; mail("[email protected]", "Information Inquiry", $message, "From: $email"); header( "Location: thankyou.php" ); } ?>

I don’t know why you added in all those extra returns in there, so I removed them.

Sponsor our Newsletter | Privacy Policy | Terms of Service