email notification from form
Posted: Tue Jan 29, 2013 3:22 pm
I run a small sporting association site and have built a forum in the administration area. What I want to do is notify all Board Members when a new Topic is inserted into the database. The current script works fine (it is within a form on an insert record page), but will only send to predefined email address or addresses. I would like to modify the "to" so it sends emails from a query. My knowledge of php is not sufficient to write it.
<?php
$to = "email@mysite.com";
$subject = "DO NOT REPLY";
$message = "This is an automated message, A new topic has been introduced in the mysite forum!";
$headers = "From: noreply@mysite.com\r\n" .
'X-Mailer: PHP/' . phpversion() . "\r\n" .
"MIME-Version: 1.0\r\n" .
"Content-Type: text/html; charset=utf-8\r\n" .
"Content-Transfer-Encoding: 8bit\r\n\r\n";
mail($to, $subject, $message, $headers)or die('An error has occurred');
?>
Would like to replace
$to = "email@mysite.com";
with the result of a query, something like
SELECT email
FROM members
WHERE boardmember is not null
Any assistance will be greatly appreciated
<?php
$to = "email@mysite.com";
$subject = "DO NOT REPLY";
$message = "This is an automated message, A new topic has been introduced in the mysite forum!";
$headers = "From: noreply@mysite.com\r\n" .
'X-Mailer: PHP/' . phpversion() . "\r\n" .
"MIME-Version: 1.0\r\n" .
"Content-Type: text/html; charset=utf-8\r\n" .
"Content-Transfer-Encoding: 8bit\r\n\r\n";
mail($to, $subject, $message, $headers)or die('An error has occurred');
?>
Would like to replace
$to = "email@mysite.com";
with the result of a query, something like
SELECT email
FROM members
WHERE boardmember is not null
Any assistance will be greatly appreciated