session_start();
include("config.php");
include("header.php");
$menu_type = "normal";
include("menu.php");
if($_SERVER['REQUEST_METHOD'] == 'POST' && !empty($_POST))
{
$error = '';
if (!isset($_POST['message'])) {
$error .= "Please fill in a message!";
}
if (!isset($_POST['subject'])) {
$error .= "Please fill in a subject!";
}
if (empty($error))
{
$sql = mysql_query("SELECT * FROM users WHERE newsletter = '1'");
while ($obj = mysql_fetch_assoc($sql)) {
mail($obj['email'], $_POST['subject'], $_POST['message'], $headers);
echo 'E-mail send to: ' . $obj['name'] . '
';
}
}
else
{
echo "Pleas fill in all the fields!";
}
}
else
{
?>