php emailer not working
i have made an online form that selects users email addresses from a PHP mysql DB and then emails them information that is inputted into a form. the form is updating the DB but the email is not being sent. can anyone help ?. the code is below
<?php require_once('../Connections/prop.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($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_update"])) && ($_POST["MM_update"] == "form2")) {
$updateSQL = sprintf("UPDATE plus_signup SET GuName=%s, GuPhoneEmail=%s, GuEmailerSubject=%s, GuEmailerContent=%s WHERE userid=%s",
GetSQLValueString($_POST['GuName'], "text"),
GetSQLValueString($_POST['GuPhoneEmail'], "text"),
GetSQLValueString($_POST['GuEmailerSubject'], "text"),
GetSQLValueString($_POST['GuEmailerContent'], "text"),
GetSQLValueString($_POST['userid'], "text"));
mysql_select_db($database_hostprop, $hostprop);
$Result1 = mysql_query($updateSQL, $hostprop) or die(mysql_error());
// Email Guarantor
$to = $_POST['GuPhoneEmail'];
$subject = "EMail From Host Student Property";
$message = "
<html>
<head>
<title>New Email</title>
</head>
<body>
<img src=\"http://www.student.combeta/images/hostlogo.gif\" alt=\"www.thestudent.com\" />
<h2>An Email From Students</h2>
<br /><br />
<table>
<tr>
<td colspan=\"2\" style=\"text-align:center;\"><strong>Email Below</strong></td>
</tr
<tr>
<td>Subject</td>
<td>".GetSQLValueString($_POST['GuEmailerSubject'], "text")."</td>
</tr>
<tr>
<td>Content</td>
<td>".GetSQLValueString($_POST['GuEmailerContent'], "text")."</td>
</tr>
</table>
</body>
</html>
";
// Always set content-type when sending HTML email
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n";
$headers .= 'From: Student.com <contact@student.com>' . "\r\n";
$send = mail($to,$subject,$message,$headers);
$updateGoTo = "GuarantorEmailSent.php";
if (isset($_SERVER['QUERY_STRING'])) {
$updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
$updateGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $updateGoTo));
}
mysql_select_db($database_hostprop, $hostprop);
$query_Recordset1 = "SELECT userid, GuName, GuPhoneEmail FROM plus_signup";
$Recordset1 = mysql_query($query_Recordset1, $hostprop) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
?>
<script type="text/javascript">
function loadFields(Value) {
var Guarantor = Value.split("|");
var GuName = Guarantor[0];
var GuPhoneEmail = Guarantor[1] ;
document.getElementById('GuName').value=GuName;
document.getElementById('GuPhoneEmail').value=GuPhoneEmail;
}
</script>
<form action="<?php echo $editFormAction; ?>" method="post" name="form2" id="form2">
<table align="center">
<tr valign="baseline">
<td nowrap="nowrap" align="right"> </td>
<td><select name="Name" id="Name" onchange="loadFields(this.value)">
<option value="Select Guarantor">Select Guarantor</option>
<?php
do {
?>
<option value="<?php echo $row_Recordset1['GuName'] . '|' . $row_Recordset1['GuPhoneEmail'];?>"><?php echo $row_Recordset1['GuName'] . " , " . $row_Recordset1['GuPhoneEmail']; ?></option>
<?php
} while ($row_Recordset1 = mysql_fetch_assoc($Recordset1));
$rows = mysql_num_rows($Recordset1);
if($rows > 0) {
mysql_data_seek($Recordset1, 0);
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
}
?>
</select></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Userid:</td>
<td><?php echo $row_Recordset1['userid']; ?></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">GuName:</td>
<td><input type="text" name="GuName" id="GuName" readonly="readonly" value="<?php echo htmlentities($row_Recordset1['GuName'], ENT_COMPAT, 'utf-8'); ?>" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">GuPhoneEmail:</td>
<td><input type="text" name="GuPhoneEmail" id="GuPhoneEmail" readonly="readonly" value="<?php echo htmlentities($row_Recordset1['GuPhoneEmail'], ENT_COMPAT, 'utf-8'); ?>" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">GuEmailerSubject:</td>
<td><input type="text" name="GuEmailerSubject" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">GuEmailerContent:</td>
<td><input type="text" name="GuEmailerContent" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right"> </td>
<td><input type="submit" value="Update record" /></td>
</tr>
</table>
<input type="hidden" name="MM_update" value="form2" />
<input type="hidden" name="userid" value="<?php echo $row_Recordset1['userid']; ?>" />
</form>
thanks is advance
