Quantcast
Channel: PHP Freaks: PHP Help
Viewing all articles
Browse latest Browse all 13200

Form not sending email

$
0
0

I have a form using php that is supposed to send me an email with the info, as well as redirect the user to "thanks.html." The user is redirected, but I do not receive an email. The form is at http://www.express1warehouse.com/thanks.html

Here is the php. Can anyone see any problems here?

<?php
/*
This first bit sets the email address that you want the form to be submitted to.
You will need to change this value to a valid email address that you can access.
*/
$webmaster_email = "sales@express1warehouse.com";

/*
This bit sets the URLs of the supporting pages.
If you change the names of any of the pages, you will need to change the values here.
*/
$feedback_page = "contact.html";
$error_page = "error_message.html";
$thankyou_page = "thanks.html";

/*
This next bit loads the form field data into variables.
If you add a form field, you will need to add it here.
*/
$contact_name = $_REQUEST['contact_name'] ;
$company_name = $_REQUEST['company_name'] ;
$phone = $_REQUEST['phone'] ;
$email = $_REQUEST['email'] ;
$website = $_REQUEST['website'] ;
$type_of_product = $_REQUEST['type_of_product'] ;
$number_of_skus = $_REQUEST['number_of_skus'] ;
$orders_per_month = $_REQUEST['orders_per_month'] ;
$units_per_order = $_REQUEST['units_per_order'] ;
$storage_details = $_REQUEST['storage_details'] ;
$ship_method = $_REQUEST['ship_method'] ;
$intl_ship_details = $_REQUEST['intl_ship_details'] ;
$inv_rec_details = $_REQUEST['inv_rec_details'] ;
$returned_inv_details = $_REQUEST['returned_inv_details'] ;
$pack_details = $_REQUEST['pack_details'] ;
$backorder_noninv_details = $_REQUEST['backorder_noninv_details'] ;
$order_integration_details = $_REQUEST['order_integration_details'] ;

/*
The following function checks for email injection.
Specifically, it checks for carriage returns - typically used by spammers to inject a CC list.
*/
function isInjected($str) {
	$injections = array('(\n+)',
	'(\r+)',
	'(\t+)',
	'(%0A+)',
	'(%0D+)',
	'(%08+)',
	'(%09+)'
	);
	$inject = join('|', $injections);
	$inject = "/$inject/i";
	if(preg_match($inject,$str)) {
		return true;
	}
	else {
		return false;
	}
}

// If the user tries to access this script directly, redirect them to the feedback form,
if (!isset($_REQUEST['email'])) {
header( "Location: $feedback_page" );
}

// If the form fields are empty, redirect to the error page.
elseif (empty($email) || empty($contact_name)) {
header( "Location: $error_page" );
}

// If email injection is detected, redirect to the error page.
elseif ( isInjected($email) ) {
header( "Location: $error_page" );
}

// If we passed all previous tests, send the email then redirect to the thank you page.
else {
mail( "$webmaster_email", "Request for Quote",
  $contact_name, $company_name, $phone, $email, $website, $type_of_product, $number_of_skus, $orders_per_month,
   $units_per_order, $storage_details, $ship_method, $intl_ship_details, $inv_rec_details, $returned_inv_details,
    $pack_details, $backorder_noninv_details, $order_integration_details, "From: $email" );
header( "Location: $thankyou_page" );
}
?>

Viewing all articles
Browse latest Browse all 13200

Trending Articles