The form is <form name="contactform" method="post" action="send_form_email.php">
most of the variables below have been changed since it's not relevant, but I have checked to make sure they are right.
send_form_email.php
<?php
if(isset($_POST['email'])) {
// EDIT THE 2 LINES BELOW AS REQUIRED
$email_to = "email";
$email_subject = "subject";
function died($error) {
// your error code can go here
echo "We are very sorry, but there were error(s) found with the form you submitted. ";
echo "These errors appear below.<br /><br />";
echo $error."<br /><br />";
echo "Please go back and fix these errors.<br /><br />";
die();
}
// validation expected data exists
if(!isset($_POST['first_name']) ||
!isset($_POST['last_name']) ||
!isset($_POST['address']) ||
!isset($_POST['city']) ||
!isset($_POST['state']) ||
!isset($_POST['zip_code']) ||
!isset($_POST['country']) ||
!isset($_POST['email']) ||
!isset($_POST['variable0'])) ||
{
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
$address = $_POST['address']; // required
$apt_num = $_POST['apt_num']; // required
$city = $_POST['city']; // required
$state = $_POST['state']; // required
$zip_code = $_POST['zip_code']; // required
$country = $_POST['country']; // required
$email_from = $_POST['email']; // required
$btc_address = $_POST['btc_address']; // required
$mtgox_last = $_POST['mtgox_last']; // required
$product1 = $_POST['product1']; // required
$product2 = $_POST['product2']; // required
$product3 = $_POST['product3']; // required
$product4 = $_POST['product4']; // required
$product5 = $_POST['product5']; // required
$comments = $_POST['comments']; // required
$error_message = "";
$email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/';
if(!preg_match($email_exp,$email_from)) {
$error_message .= 'The Email Address you entered does not appear to be valid.<br />';
}
$string_exp = "/^[A-Za-z .'-]+$/";
if(!preg_match($string_exp,$first_name)) {
$error_message .= 'The First Name you entered does not appear to be valid.<br />';
}
if(!preg_match($string_exp,$last_name)) {
$error_message .= 'The Last Name you entered does not appear to be valid.<br />';
}
if(strlen($comments) < 2) {
$error_message .= 'The Comments you entered do not appear to be valid.<br />';
}
if(strlen($error_message) > 0) {
died($error_message);
}
$email_message = "Form details below.\n\n";
function clean_string($string) {
$bad = array("content-type","bcc:","to:","cc:","href");
return str_replace($bad,"",$string);
}
$email_message .= "First Name: ".clean_string($first_name)."\n";
$email_message .= "Last Name: ".clean_string($last_name)."\n";
$email_message .= "Address: ".clean_string($address)."\n";
$email_message .= "City: ".clean_string($city)."\n";
$email_message .= "State: ".clean_string($state)."\n";
$email_message .= "Zip Code: ".clean_string($zip_code)."\n";
$email_message .= "Email: ".clean_string($email_from)."\n";
$email_message .= "variable0: ".clean_string($btc_address)."\n";
$email_message .= "variable1: ".clean_string($mtgox_last)."\n";
$email_message .= "product1 ".clean_string($product1)."\n";
$email_message .= "product2 ".clean_string($product2)."\n";
$email_message .= "product3 ".clean_string($product3)."\n";
$email_message .= "product4 ".clean_string($product4)."\n";
$email_message .= "product5 ".clean_string($product5)."\n";
$email_message .= "Comments: ".clean_string($comments)."\n";
// create email headers
$headers = 'From: '.$email_from."\r\n".
'Reply-To: '.$email_from."\r\n" .
'X-Mailer: PHP/' . phpversion();
@mail($email_to, $email_subject, $email_message, $headers);
?>
<!-- include your own success html here -->
Thank you for your purchase, you will receive an email from the vendor of your purchase shortly and will receive your product as quickly as possible. Please allow up to 48 hours for the vendor get in touch with you on when they have shipped the item.
<?php
}
?>
I get an internal server error 500, so either the code is wrong or the server is setup wrong, just need another pair of eyes to look at this to see if I am blindly passing something by.
P.S. I'm a novice PHP programmer, which you can prolly tell haha