I have a problem with the email script of this .php code. When the page loads, it automatically sends a blank email with the form variables in it. Then when the customer fills out the form fields and presses submit, I get another email, but with the information... Why is this. I have honestly tried everything and no one can seem to help me.. Below is the .php script on the page and in the next post is the form variable in html...
<?php require_once('Connections/emall.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"] == "Contact")) {
$insertSQL = sprintf("INSERT INTO nvcontact (Full_Name, Email_Address, Comments, `Business Name`, `Phone Number`) VALUES (%s, %s, %s, %s, %s)",
GetSQLValueString($HTTP_POST_VARS['Fname'], "text"),
GetSQLValueString($HTTP_POST_VARS['Eaddress'], "text"),
GetSQLValueString($HTTP_POST_VARS['Comment'], "text"),
GetSQLValueString($HTTP_POST_VARS['Bname'], "text"),
GetSQLValueString($HTTP_POST_VARS['Phone'], "text"));
mysql_select_db($database_emall, $emall);
$Result1 = mysql_query($insertSQL, $emall) or die(mysql_error());
$insertGoTo = "/Email/Confirm.php";
if (isset($HTTP_SERVER_VARS['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $HTTP_SERVER_VARS['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
mail("kyle@ntlnk.com", "Nevada Matters Comment", "The following has been submitted by a customer at: [url]www.nevadamatters.com.\r\n\r\n[/url]
-------------------------------------------------------------------------------------------------------------------------------------------------\r\n\r\n\r\n\r\n
Customers Name: $Fname\r\n
Businesses Name: $Bname\r\n
Email Address: $Eaddress\r\n
Phone Number: $Phone\r\n
Comments: $Comment\r\n\r\n
--------------------------------------------------------------------------------------------------------------------------------------------------\r\n\r\n",
"From: [email]support@nevadamatters.com[/email]\r\n".
"Reply-To: [email]sales@nevadamatters.com[/email]\r\n".
"Return-Path: [email]info@nevadamatters.com[/email]\r\n");
?>