gæstebog..
har en gæstebog som fra flash snakker sammen med et php.doc.Kunne godt tænke mig at de nyeste indlæg lå først og ikke sidst som de gør nu. Er der nogle der ved hvordan jeg gør?
Koden ser sådan ud:
<?
if (!isset($name) || !isset($email) || !isset($message) || empty($name) || empty($email) || empty($message)) {
print "&result=Fail";
print "&errorMsg=" . urlencode("Input required for all fields.");
exit;
}
$email = strtolower($email);
addentry($name, $email, $message);
function addentry($name, $email, $message) {
$posted = strftime("%D %I:%M %p");
$message = utf8_encode($message);
$name = utf8_encode($name);
$email = utf8_encode($email);
$file = fopen('entry.txt', 'a+');
if (!$file) {
print "&result=Fail";
print "&errorMsg=" . urlencode("Could not open entry.txt file. Change CHMOD levels to 766.");
exit;
}
fputs($file, "<font color=\"#000000\">Name:</font> $name\n<font color=\"#000000\">Email:</font> <font color=\"#CCCCCC\"><u><A href=\"mailto:$email\">$email</A></u></font><br>\n<font color=\"#000000\">Posted:</font> $posted\n<font color=\"#000000\">Message:</font> $message\n\n");
fclose($file);
// Send admin an email when new entry occurs
// mailAdmin($name, $email);
}
function mailAdmin($name, $email) {
$mailTo = "Your Name <n@hotmail.com>";
$mailFrom = "From: Guestbook <n@hotmail.com>";
$mailSubject = "New Guestbook Entry";
$mailBody = "$name ($email) has just posted in your guestbook\n\nView it at http://www.nicod2.com";
mail($mailTo, $mailSubject, $mailBody, $mailFrom);
}
print "&result=okay";
exit;
?>