I've only just started to test the scripts properly now (as I did the test as I went along and it all seemed fine but now but now the remove function does not work again. I rewrote the code from the tutorial but is not working. It looks as though everything is working as it should though. Is there any suggestions or Ideas?
<?php
// ADDS DETAILS INTO THE DB
function add_user($email){
$email = mysql_real_escape_string($email);
$result = mysql_query ("INSERT INTO `users` (`email`) VALUES (`{$email}`)");
return ($result !== false) ? true : false;
}
// REMOVES THE EMAIL ADDRESS FROM THE TABLE
function remove_user($email){
$email = mysql_real_escape_string($email);
mysql_query("DELETE FROM `users` WHERE `email` = `{$email}`");
}
// SENDS MESSAGE TO ALL USRES
$headers = array (
'From: name@website.co.uk'. "\r\n" .
'Content-type: text/html; charset=iso-8859-1' . "\r\n" .
'X-Mailer: PHP/' . phpversion()
);
function mail_all($subject, $message, $headers){
$users = mysql_query("SELECT `email` FROM `users`");
while (($user = mysql_fetch_assoc($users))!== false){
$body = "Hi, <p></p> {$message} <p></p>
<b>Unsubscribe:</b> http://www.nameofsite/content/subscribe ... ail={$user['email']}";
mail($user['email'], $subject, $body, $headers);
}
}
Many Thanks 