Hvad er der galt med dette??
<?/*
PHP/MySQL Maillingliste
Copyright Christian Thuner
-------------------------------------
Denne mail-liste har jeg lavet
specielt til mit eget brug, og andres.
Hvis du laeser denne tekst, vil jeg håbe
at du kan bruge maillinglisten godt.
Du skal oprette en MySQL tabel, med
felterne: name, email og id.
Med Venlig Hilsen
Christian Thuner
http://cht.dk/
cht@cht.dk
-------------------------------------
*/
// Generel konfiguration
$snd_from = "cht@cht.dk"; // Afsender e-mail
$title = "Christian's MailListe"; // Titlen
$log = "maillist-log.txt"; // Log-fil
$msg_title = "CHT.dk Nyhedsbrev"; // Titlen/emnet på nyhedsbrevet
$password = "Password"; // Password til sender siden
// SQL konfiguration
$host = "cht.dk"; // MySQL server navnet
$db = "Database"; // Databasen der skal arbjedes i
$tb = "Tabel"; // Tabellen der skal arbjedes i
$us = "Brugernavn"; // Databasens brugernavn
$pass = "Password"; // Databasens password
// Konfigurationen er slut
/* ---- DO NO DELETE AFTER THIS LINE! ---- */
?>
<html>
<head>
<title> <? echo $title; ?></title>
<link rel="stylesheet" href="../style.css" type="text/css">
</head>
<body>
<?
$date = date( "d/m/Y", time());
$time = date( "H:i:s", time());
$user = $HTTP_USER_AGENT;
$conn = mysql_connect($host, $us, $pass);
mysql_select_db($db);
if (($action == "postmsg") && ($pw == $password)) {
echo "<h2>Send besked til brugerne</h2><hr color=\"#000000\" size=\"1\">\n";
echo "<form method=\"post\" action=\"".$PHP_SELF. "\">\n";
echo "<input type=\"hidden\" name=\"action\" value=\"savemsg\">\n";
echo "<b>Indtast den besked, der skal udsendes til alle brugerne:</b><br>\n";
echo "<textarea rows=\"11\" name=\"message\" cols=\"48\"></textarea><br>\n";
echo "<input type=\"submit\" value=\"Send\"></form>";
}
elseif ($action == "sndmsg") {
echo "<h2>Send besked til brugere</h2><hr color=\"#000000\" size=\"1\">\n";
echo "<form method=\"post\" action=\"".$PHP_SELF. "\">\n";
echo "<input type=\"hidden\" name=\"action\" value=\"postmsg\">\n";
echo "<b>Indtast password:</b><br>\n";
echo "<input type=\"password\" name=\"pw\"><br>\n";
echo "<input type=\"submit\" value=\"Login\"></form>\n";
}
elseif ($action == "viewall") {
echo "<h2>Alle brugere</h2><hr color=\"#000000\" size=\"1\">\n";
$query = mysql_query( "SELECT*FROM $tb");
while ($row = mysql_fetch_array($query))
{
echo "<b>".$row[name]. "</b> - <a href=\"mailto:".$row[email]. "\">".$row[email]. "</a> - ID: ".$row[id]. "<br><br>\n";
}
}
elseif ($action == "signup") {
echo "<h2>Tilmeld dig</h2><hr color=\"#000000\" size=\"1\">\n";
echo "<form method=\"post\" action=\"".$PHP_SELF. "\">\n";
echo "<input type=\"hidden\" name=\"action\" value=\"saveuser\">\n";
echo "<b>Indtast dit navn:</b><br>\n";
echo "<input type=\"text\" name=\"name\"><br>\n";
echo "<b>Indtast din e-mail adresse:</b><br>\n";
echo "<input type=\"text\" name=\"email\"><br>\n";
echo "<input type=\"submit\" value=\"Send\"></form>";
}
elseif ($action == "savemsg" && $message) {
// Skriver til log-filen
$fp = fopen($log, "a+");
fputs($fp, "$date - $time - $user : Besked blev sendt");
fclose($fp);
// Log writeren ender
$take = mysql_query( "SELECT*FROM $tb");
while ($addr = mysql_fetch_array($take)) {
mail($addr[email], $msg_title, $message, "from: $snd_from");
}
echo "<b>Beskeden blev sendt!</b><br>\n";
echo "<a href=\"".$PHP_SELF. "\">Til maillistens forside</a>\n";
}
elseif ($action == "saveuser" && $email && $name) {
// Skriver til log-filen
$fp = fopen($log, "a+");
fputs($fp, "$date - $time - $user : Brugeren $name ($email) blev gemt");
fclose($fp);
// Log writeren ender
$num = mysql_query( "SELECT*FROM $tb");
$id = mysql_num_rows($num)+1;
mysql_query( "INSERT INTO $tb (email, name, id) VALUES ('$email','$name','$id')");
echo "<h2>Gem bruger</h2><hr color=\"#000000\" size=\"1\">\n";
echo "<b>Brugeren blev gemt!</b><br>\n";
echo "Dette ID nummer skal gemmes hvis du senere ønsker at afmelde dig maillisten:<br>\n";
echo "<small><b>".$id. "</b></small><br><br>\n";
echo "<a href=\"".$PHP_SELF. "\">Til maillistens forside</a>\n";
}
elseif ($action == "deleteuser") {
echo "<h2>Slet en bruger</h2><hr color=\"#000000\" size=\"1\">\n";
echo "<form method=\"post\" action=\"".$PHP_SELF. "\">\n";
echo "<input type=\"hidden\" name=\"action\" value=\"deluser\">\n";
echo "<b>Indtast dit bruger-ID: (Det du fik ved tilmeldingen)</b><br>";
echo "<input type=\"text\" name=\"id\" size=\"3\"><br>\n";
echo "<b>Indtast din e-mail adresse:<br>\n";
echo "<input type=\"text\" name=\"email\" size=\"20\"><br>\n";
echo "<input type=\"submit\" value=\"Udfør\"></form>\n";
}
elseif ($action == "deluser" && $id && $email) {
// Skriver til log-filen
$fp = fopen($log, "a+");
fputs($fp, "$date - $time - $user : Brugeren $id blev slettet");
fclose($fp);
// Log writeren ender
mysql_query( "DELETE FROM $tb WHERE id = '$id' AND email = '$email'");
echo "<h2>Slet bruger</h2><hr color=\"#000000\" size=\"1\">\n";
echo "<b>Brugeren blev slettet</b><br>\n";
echo "<a href=\"".$PHP_SELF. "\">Til maillistens forside</a>\n";
}
else
{
echo "<h2>".$title. "</h2><hr color=\"#000000\" size=\"1\">\n";
echo "<b>[<a href=\"".$PHP_SELF. "?action=sndmsg\">Send besked til brugere</a>]<br><br>\n";
echo "[<a href=\"".$PHP_SELF. "?action=signup\">Tilmeld bruger</a>]<br><br>\n";
echo "[<a href=\"".$PHP_SELF. "?action=deleteuser\">Slet bruger</a>]</b>\n";
}
mysql_close($conn);
?>
</body>
</html>