Possible Duplicate:
Simple PHP Mailer Script
i run a small website and we have had requests for a mailing list….
i have found a simple free script to add email addresses to a txt file – “email.txt” (which is protected) is csv format (email1@yahoo.com,email2@yahoo.com,blah,blah,blah)
this script works flawlessly…..
however it is a nuciance to go through this text file to manually remove email addresses when users cancel their subscription to the mailing list…..
i am having trouble creating a simple script to remove email addresses….
so far i have ….
<html>
<body>
<form method="post" action="">
<p>Email Address: <input type="text" name="email"></p>
<input type="submit" value="Cancel Newsletter" name="submit">
</form>
<?php
$email = $_POST["email"];
$text = file_get_contents("email.txt");
$oldWord = "$email";
$newWord = "";
$text = str_replace($oldWord , $newWord , $text);
$fp = fopen('email.txt', 'w');
fwrite($fp, $text);
fclose($file);
?>
</body>
</html>
this works perfect to remove the email address from the list…..
however i cannot figure out how to echo a comment dependant on whether
str_replace($oldWord , $newWord , $text);
is successful at replacing the email address with an empty space….
if the code removes email address i would like “You Have Been Removed From The Flying Shuttle Newsletter.”
and if the email address isnt there (code doesnt replace email with empty space)
“The Email Address You Specified Is Not On The Mailing List!”
thanks in advance for any help
You could just compare the length of the returned string.