Hi,
I have a PHP guestbook intergrated into my flash movie, but when new entries are added they go to the bottom - I would like the newest entry to always be at the top. Can anyone please help?
Here is the PHP code:
<?
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 = stripslashes($message);
$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=”#ffffff">Name:</font> $name
<font color="#ffffff">Email:</font><font color="#ffffff"><A href=“mailto:$email”> $email</A></font><br>
<font color="#ffffff">Posted:</font> $posted
<font color="#ffffff">Message:</font> $message
");
fclose($file);
// Send admin an email when new entry occurs
mailAdmin($name, $email, $message);
}
function mailAdmin($name, $email, $message) {
$mailTo = "[email protected]";
$mailFrom = “From: <[email protected]>”;
$mailSubject = “New Guestbook Entry”;
$mailBody = "A visitor to your site has left the following information in your guestbook:
Name: $name
Email: $email
The visitor commented:
------------------------------
$message
------------------------------
You can view the message at:
http://www.yoursite.com";
mail($mailTo, $mailSubject, $mailBody, $mailFrom);
mail($email, "Your Subject", "Thank you message", "From: [email][email protected][/email]");
}
print “&result=okay”;
exit;
?>