$sql = "SELECT * FROM leads WHERE accesstoken = '".$_POST["userAc"]."'";
$result = mysql_query($sql) or trigger_error("Query Failed: " . mysql_error());
if(mysql_num_rows($result)>0)
{
while($row = mysql_fetch_array($result))
{
$id= $row['id'];
$fullname= $row['fullname'];
$email= $row['email'];
$to = $email;
$message .= $_POST["userMessage"];
$subject = $_POST["userSubject"];
$headers = "From: " . $_POST["userEmail"] . "\r\n";
$headers .= "Reply-To: ". $_POST["userEmail"] . "\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
if (mail($to, $subject, $message, $headers))
{
$output = json_encode(array('type'=>'error', 'text' => '<p>Your Message was sent successfully!</p>'));
die($output);
}
else
{
$output = json_encode(array('type'=>'error', 'text' => '<p>Your Message was not sent!</p>'));
die($output);
}
}
}
I have another table called accounts
that I want to join with this one, I need to select from ref to get the email from account table also!
be something like this
$sql = "SELECT * FROM accounts WHERE ref = '".$_POST["userAc"]."'";
$result = mysql_query($sql) or trigger_error("Query Failed: " . mysql_error());