Hovsa da, sådan skulle det gerne se ud i virkeligheden:
<?
// Maillist script
// Made by Christian Thuner
// E-mail: cht@cht.dk
// Find more at
www.cht.dk// General config
$titl = "My maillist";
$from = "cht@cht.dk";
// MySql config
$db = "maillist";
$host = "localhost";
$user = "root";
$pw = "";
// Style config
$text = "arial";
$size = "4";
// End of configuration
// ----------- Do not delete this line! -----------
$mess = ereg_replace("-br","\n","$mess");
$mess = ereg_replace("<>","","$mess");
mysql_connect("$host", "$user");
mysql_select_db("$db");
if ($action == "saveuser") {
mysql_query("INSERT INTO users (name, email) VALUES ('$name','$email')");
echo "<b>You are saved i the database!</b><br>";
} else
if ($action == "deleteuser") {
mysql_query("DELETE FROM users WHERE email = $email");
mysql_query("DELETE FROM users WHERE name = $name");
echo "<b>The user, $name, has been deleted!</b>";
}
if ($action == "savemsg") {
$result = mysql_query("SELECT*FROM users");
while ($field = mysql_fetch_array("$result")) {
mail("$field[email]", "$titl - $subject", "$mess", "from: $from");
}
echo "<p><b>Ok, you have mailed all users!<br>";
echo "You has written:</b><br>".$mess."<br>";
echo "<hr color=\"#000000\" size=\"1\">";
} else
if ($action == "vusers") {
$work = mysql_query("SELECT*FROM users");
while ($view = mysql_fetch_array("$work")) {
echo "<p><b><small><small>".$view[name]."</b> - ".$view[email]."</small></small></p>";
}
} else
if ($action == "deluser") {
echo "<p><h2><font face=\"".$text."\" size=\"".$size."\">".$titl."</h2><hr color=\"#000000\" size=\"1\">";
echo "<b>Delete a user</b><br>";
echo "<form method=\"post\" action=\"".$PHP_SELF."?action=deleteuser\">";
echo "You name: <input type=\"text\" name=\"name\" size=\"30\"><br>";
echo "You E-Mail address:<br>";
echo "<input type=\"text\" name=\"email\" size=\"40\"><br>";
echo "<input type=\"submit\" value=\"Save user\">";
echo "<hr color=\"#000000\" size=\"1\">";
echo "<a href=\"".$PHP_SELF."\">Back to main</a></font></p>";
echo "</form>";
}
if ($action == "newuser") {
echo "<p><h2><font face=\"".$text."\" size=\"".$size."\">".$titl."</h2><hr color=\"#000000\" size=\"1\">";
echo "<b>Add a user to ".$titl."</b><br>";
echo "<form method=\"post\" action=\"".$PHP_SELF."?action=saveuser\">";
echo "You name: <input type=\"text\" name=\"name\" size=\"30\"><br>";
echo "You E-Mail address:<br>";
echo "<input type=\"text\" name=\"email\" size=\"40\"><br>";
echo "<input type=\"submit\" value=\"Save user\">";
echo "<hr color=\"#000000\" size=\"1\">";
echo "<a href=\"".$PHP_SELF."\">Back to main</a></font></p>";
echo "</form>";
} else
if ($action == "newmsg") {
echo "<p><h2><font face=\"".$text."\" size=\"".$size."\">".$titl."</h2><hr color=\"#000000\" size=\"1\">";
echo "<b>Send af message to users</b><br>";
echo "<form method=\"post\" action=\"".$PHP_SELF."?action=savemsg\">";
echo "Subject: <input type=\"text\" name=\"subject\" size=\"30\"><br>";
echo "Message (use -br to linebreak):<br>";
echo "<textarea rows=\"14\" name=\"mess\" cols=\"64\"></textarea><br>";
echo "<input type=\"submit\" value=\"Send message\">";
echo "<hr color=\"#000000\" size=\"1\">";
echo "<a href=\"".$PHP_SELF."\">Back to main</a></font></p>";
echo "</form>";
} else
{
echo "<p><h2><font face=\"".$text."\" size=\"".$size."\">".$titl."</h2><hr color=\"#000000\" size=\"1\">";
echo "<li><em><a href=\"".$PHP_SELF."?action=vusers\">View all users</a></li></em>";
echo "<li><em><a href=\"".$PHP_SELF."?action=deluser\">Delete a user</a></li></em>";
echo "<li><em><a href=\"".$PHP_SELF."?action=newuser\">Add user to ".$titl."</a></li></em>";
echo "<li><em><a href=\"".$PHP_SELF."?action=newmsg\">Post new message to users</a></li></em>";
echo "<hr color=\"#000000\" size=\"1\">";
}
mysql_free_result("$result");
mysql_free_result("$work");
mysql_close();
?>