I'am sending two emails from this .php page and the problem that I'm having is that there are two emails being sent to Info@nevadasmarthomes.com for the second email script. The first email that I recieve, has all blank fields in it, the second one has the customers information that he/she has entered. Is there a problem with my script? I would appreciate any help on this.
<?php require_once('Connections/smarthomes.php');?>
<?php
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
$editFormAction = $HTTP_SERVER_VARS['PHP_SELF'];
if (isset($HTTP_SERVER_VARS['QUERY_STRING'])) {
$editFormAction .= "?" . $HTTP_SERVER_VARS['QUERY_STRING'];
}
if ((isset($HTTP_POST_VARS["MM_insert"])) && ($HTTP_POST_VARS["MM_insert"] == "Contact1")) {
$insertSQL = sprintf("INSERT INTO Contact1 (`Contact By`, `Project Location`, `Project Type`, `Number Of Bedrooms`, `Number Of Bathrooms`, `Square Footage`, `Total Home/Office Automation`, `Lighting/Scene Control`, HVAC, `Whole Home/Office Audio`, `Home Theater`, `Advanced Irrigation`, `Enhanced Security Control`, `Touch-Screen Operation Upgrade`, `Advanced Remote Access`, `First Name`, `Last Name`, Address, City, `State`, Zip, `Email Address`, `Home Phone#`, `Personal Info Authorization`, Comments, `Alternate Phone#`) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($HTTP_POST_VARS['ContactBy'], "text"),
GetSQLValueString($HTTP_POST_VARS['ProjectLocation'], "text"),
GetSQLValueString($HTTP_POST_VARS['Typeofproject'], "text"),
GetSQLValueString($HTTP_POST_VARS['Bedrooms'], "int"),
GetSQLValueString($HTTP_POST_VARS['Bathrooms'], "int"),
GetSQLValueString($HTTP_POST_VARS['Squarefootage'], "int"),
GetSQLValueString($HTTP_POST_VARS['Automation'], "text"),
GetSQLValueString($HTTP_POST_VARS['Lighting'], "text"),
GetSQLValueString($HTTP_POST_VARS['HVAC'], "text"),
GetSQLValueString($HTTP_POST_VARS['Audio'], "text"),
GetSQLValueString($HTTP_POST_VARS['Theater'], "text"),
GetSQLValueString($HTTP_POST_VARS['Irrigation'], "text"),
GetSQLValueString($HTTP_POST_VARS['Enhanced'], "text"),
GetSQLValueString($HTTP_POST_VARS['Touch'], "text"),
GetSQLValueString($HTTP_POST_VARS['Remote'], "text"),
GetSQLValueString($HTTP_POST_VARS['FirstName'], "text"),
GetSQLValueString($HTTP_POST_VARS['LastName'], "text"),
GetSQLValueString($HTTP_POST_VARS['Address'], "text"),
GetSQLValueString($HTTP_POST_VARS['City'], "text"),
GetSQLValueString($HTTP_POST_VARS['State'], "text"),
GetSQLValueString($HTTP_POST_VARS['Zip'], "int"),
GetSQLValueString($HTTP_POST_VARS['Email'], "text"),
GetSQLValueString($HTTP_POST_VARS['HomePhone'], "text"),
GetSQLValueString($HTTP_POST_VARS['Authorization'], "text"),
GetSQLValueString($HTTP_POST_VARS['Comments'], "text"),
GetSQLValueString($HTTP_POST_VARS['AlternatePhone'], "text"));
mysql_select_db($database_smarthomes, $smarthomes);
$Result1 = mysql_query($insertSQL, $smarthomes) or die(mysql_error());
$insertGoTo = "Request/Confirm.php";
if (isset($HTTP_SERVER_VARS['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $HTTP_SERVER_VARS['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
mail($Email, "Your Request", "Dear: $FirstName\r\n
Thank you for submitting your request. Our staff is reviewing your information and will contact you soon.\r\n\r\n\r\n\r\n
---------------------------------------------------------------------------------------------------------------------------------
You have recieved this email by submitting a contact form at: [url]http://www.nevadasmarthomes.com[/url]
---------------------------------------------------------------------------------------------------------------------------------\r\n",
"From: [email]Info@nevadasmarthomes.com[/email]\r\n".
"Reply-To: [email]Info@nevadasmarthomes.com[/email]\r\n".
"Return-Path: [email]Info@nevadasmarthomes.com[/email]\r\n");
mail("Info@nevadasmarthomes.com", "Submitted Contact for [url]www.Nevadasmarthomes.com[/url]", "
------------------------------------------------------------------------------------------------------------------------------------
The following is the clients personal information, submitted at [url]http://www.nevadasmarthomes.com:[/url]
------------------------------------------------------------------------------------------------------------------------------------\r\n
First Name: $FirstName\r\n
LastName: $LastName\r\n
Address: $Address\r\n
City: $City, State: $State, Zip: $Zip\r\n
Email: $Email\r\n
Home Phone#: $HomePhone\r\n
Alternate Phone#: $AlternatePhone\r\n
Please Contact me by: $ContactBy\r\n
Project Location: $ProjectLocation\r\n
Project Type: $Typeofproject\r\n
My home/office has this many bedrooms: $Bedrooms\r\n
My home/office has this many Bathrooms: $Bathrooms\r\n
My home/office is approximately this many square feet: $Squarefootage\r\n
---------------------------------------I'm Interested in:----------------------------------\r\n\r\n
Total Home/Office Automation: $Automation\r\n
Lighting/Scene Control: $Lighting\r\n
HVAC: $HVAC\r\n
Whole Home/Office Audio: $Audio\r\n
Home Theater: $Theater\r\n
Advanced Irrigation Control: $Irrigation\r\n
Enhanced Security Control: $Enhanced\r\n
Touch-Screen Operation Upgrade: $Touch\r\n
Advanced Remote Access: $Remote\r\n
------------------------------------------------------------------------------------------------\r\n\r\n
Authorization of use of personal information: $Authorization\r\n
Comments: $Comments",
"From: [email]Info@nevadasmarthomes.com[/email]\r\n".
"Reply-To: [email]Info@nevadasmarthomes.com[/email]\r\n".
"Return-Path: [email]Info@nevadasmarthomes.com[/email]\r\n");
?>