Full-service Internet Marketing & Web Development
Recent Posts

Sponsors
![]() |
Newsletter Spit OutCode Wizard, 12-30-2006 |
Simple little newsletter or mailing list script for small websites. Great way to send an e-mail to lots of your friends.
<?
/*
Newsletter Spit Out Copyright 2000 Brian Ross
Version 1.0
brian@evilwalrus.com
AIM: DeadBrain3
ICQ: 15273600
http://www.evilwalrus.com
How to install:
1. Edit the variables below.
2. Put up this form on your page:
<form action="newsletter.phtml" method="post">
<center><div class="b"><b>Newsletter</b><br>
<input type="text" name="email" size="16"><br>
<input type="radio" name="action" value="add">Subscribe<br>
<input type="radio" name="action" value="del">Unsubscribe<br>
<input type="submit" value="-Submit-"><input type="reset" value="-Reset-"></center>
</form>
3. Use this to create a MySQL table to store the e-mail addresses in:
CREATE TABLE newsletter (email TEXT NOT NULL)
*/
$pass = "password"; // Password to be used to send the newsletter
$adminemail = "email@domain.com"; // Your email address
$name = "OnCrack.net Newsletter"; // Name of your list
$mysqluser = "user"; // MySQL user name
$mysqlpass = "password"; // MySQL password
$mysqldb = "db"; // MySQL database
$mysqltable = "table"; // MySQL table
$url = "http://www.domain.com/script.php"; // URL to this script
//Logs into MySQL
mysql_connect('localhost',$mysqluser,$mysqlpass);
mysql_select_db($mysqldb);
//Adds and removes e-mail addresses from the newsletter
if ($action == "add") {
mysql_query("insert into $mysqltable values ('$email')");
if (mysql_error() == "") {
echo "<small>Your e-mail address <b>$email</b> has been successfully added to the newsletter.</small><br>
";
mail("$email", "$name: You've Been Added", "Hello. This e-mail has been sent to welcome you to the $name. If you feal you feel that you were added to this newsletter on accident you can visit $url?action=del&email=$email. Otherwise, enjoy the list!!", "From: $adminemail");
}
else {
echo "<small>There was an error in adding your e-mail address to the newsletter.</small><br>
";
}
}
elseif ($action == "del") {
mysql_query("delete from $mysqltable where email = '$email'");
if (mysql_error() == "") {
echo "<small>Your e-mail address <b>$email</b> has been successfully removed from the newsletter.</small><br>
";
}
else {
echo "<small>There was an error in removing your e-mail address from the newsletter.</small><br>
";
}
}
elseif ($action == "admin") {
if ($password != "$pass") {
echo "<form action="$HTTP_SCRIPT_NAME" method="post"><input type="hidden" name="action" value="admin"><input type="hidden" name="type" value="1">Password: <input type="password" name="password"></form>";
}
else {
if ($type == "3") {
$result = mysql_query("SELECT * FROM newsletter");
while($row = mysql_fetch_row($result)) {
mail("$row[0]", "$name: $subject", "$message", "From: $adminemail");
}
}
if ($type == "2") {
$result = mysql_query("SELECT * FROM newsletter");
while($row = mysql_fetch_row($result)) {
mail("$row[0]", "$name: $subject", "$message", "From: $adminemail");
}
echo "<small>The mail has been sent.</small>";
}
if ($type == "1") {
echo "<table border=2><tr><td>
";
echo "<form action="$HTTP_SCRIPT_NAME" method="post">
";
echo "<input type="hidden" name="type" value="2">
";
echo "<input type="hidden" name="action" value="admin">
";
echo "<input type="hidden" name="password" value="$pass">
";
echo "<b>Subject:</b><br>
";
echo "<input type="text" name="subject" size="92"><p>
";
echo "<b>Message:</b><br>
";
echo "<textarea name="message" cols="80" rows="15"></textarea><br>
";
echo "<input type="submit" value="-Send the Mail-"> <input type="reset" value="-Clear the Data-">
";
echo "</form>
";
echo "</td><td>
";
echo "<form action="$HTTP_SCRIPT_NAME" method="post">";
echo "<input type="hidden" name="action" value="del">";
echo "<select name="email" size=19>
";
$get = mysql_query("select * from $mysqltable");
while ($row = mysql_fetch_array($get)) {
echo "<option value="$row[0]">$row[0]";
}
echo "</select>
";
echo "<br><center><input type="submit" value="-Delete-"></center>";
echo "</form>
";
echo "</td></tr></table>
";
}
}
}
?>
|
|
Subscribe Now to receive new posts via Email as soon as they come out.
Comments
Post your comments

