My script runs perfect and inserts my form data into the database but it does not email the user.
Can you look at the top part of my script and tell me why?
Is it because its not grabbing the persons address?
I think there is a problem with $to_address = $_GET['email']; email is the value of that field on this same page.
Code: Select all
<?php
include 'clientmessage.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 = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
$insertSQL = sprintf("INSERT INTO Customers (PlayLevel, Source, SourceDes, WithFriend, School, Sponsor, Asst, HCoach, CoachName, CoachDOB, CoachSSN, ShirtSize, CoachAddr, CoachPh, CoachEmail, Bcheck, Agreement, ModelRel, Name, ChildName, ChildShirt, addr1, addr2, City, `State`, Zip, Phone1, Phone2, email1, email2, Age, Birthday, Location) 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, %s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['PlayLevel'], "text"),
GetSQLValueString($_POST['Source'], "text"),
GetSQLValueString($_POST['SourceDes'], "text"),
GetSQLValueString($_POST['WithFriend'], "text"),
GetSQLValueString($_POST['School'], "text"),
GetSQLValueString(isset($_POST['Sponsor']) ? "true" : "", "defined","'Y'","'N'"),
GetSQLValueString(isset($_POST['Asst']) ? "true" : "", "defined","'Y'","'N'"),
GetSQLValueString(isset($_POST['HCoach']) ? "true" : "", "defined","'Y'","'N'"),
GetSQLValueString($_POST['CoachName'], "text"),
GetSQLValueString($_POST['CoachDOB'], "date"),
GetSQLValueString($_POST['CoachSSN'], "text"),
GetSQLValueString($_POST['ShirtSize'], "text"),
GetSQLValueString($_POST['CoachAddr'], "text"),
GetSQLValueString($_POST['CoachPh'], "text"),
GetSQLValueString($_POST['CoachEmail'], "text"),
GetSQLValueString(isset($_POST['Bcheck']) ? "true" : "", "defined","'Y'","'N'"),
GetSQLValueString(isset($_POST['Agreement']) ? "true" : "", "defined","'Y'","'N'"),
GetSQLValueString(isset($_POST['ModelRel']) ? "true" : "", "defined","'Y'","'N'"),
GetSQLValueString($_POST['Name'], "text"),
GetSQLValueString($_POST['ChildName'], "text"),
GetSQLValueString($_POST['ChildShirt'], "text"),
GetSQLValueString($_POST['addr1'], "text"),
GetSQLValueString($_POST['addr2'], "text"),
GetSQLValueString($_POST['City'], "text"),
GetSQLValueString($_POST['State'], "text"),
GetSQLValueString($_POST['Zip'], "text"),
GetSQLValueString($_POST['Phone1'], "text"),
GetSQLValueString($_POST['Phone2'], "text"),
GetSQLValueString($_POST['email1'], "text"),
GetSQLValueString($_POST['email2'], "text"),
GetSQLValueString($_POST['Age'], "text"),
GetSQLValueString($_POST['Birthday'], "text"),
GetSQLValueString($_POST['Location'], "text"));
mysql_select_db($database_custs, $custs);
$Result1 = mysql_query($insertSQL, $custs) or die(mysql_error());
$to_address = $_GET['email'];
mail ("$to_address", "$subject", "$mail_body", "From: info@mywebsite.com");
$insertGoTo = "/SignupComplete.htm";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
?>