reversing order in guestbook

I have a very simple guestbook beta here: http://flamencopeko.net/guestbook/

I need to have the most recent posts at top.

Security is not yet implemented.

Files:
addguestbook.php
guestbook.txt
index.php

Here’s a .zip: http://flamencopeko.net/guestbook/guestbook.zip

This is from http://www.hawkee.com/snippet/959/#c102523.c102690

http://www.php.net/manual/en/function.fopen.php

$handle = fopen(“c:\folder\resource.txt”, “a”);

Should work with x instead of a.

Also tried
$fp = fopen($file,“c”);
as line 29.

Only
$fp = fopen($file,“c”);
works for me.
But with wrong order of course.

[php]

Flamenco Peko

<?php require($DOCUMENT_ROOT . "../toc.php"); ?>
guestbook // feel free to sign

<table cellspacing="0">	
Name:


Email:


Home Page:


Message:


 

<?php $file = "guestbook.txt"; if (fopen($file, "r")) { $fil = "guestbook.txt"; $fo = fopen ($fil, "r"); $con = fread ($fo,filesize ($fil)); fclose ($fo); echo "$con"; } else { echo "Sorry. There was an error!"; } ?>

<?php require($DOCUMENT_ROOT . "../footer.php"); ?>

[/php]

[php]

<?php $file = "guestbook.txt"; $name = $_POST['name']; $email = $_POST['email']; $site = $_POST['site']; $msg = $_POST['msg']; $site = stripslashes($site); $msg = stripslashes($msg); $email = stripslashes($email); $name = stripslashes($name); $msg = str_replace ("<","<",$msg); $msg = str_replace ("\n","
",$msg); $site = str_replace ("<","<",$site); $site = str_replace ("\n","
",$site); $email = str_replace ("<","<",$email); $email = str_replace ("\n","
",$email); $name = str_replace ("<","<",$name); $name = str_replace ("\n","
",$name);

if(empty($email) || empty($name) || empty($msg)) {
echo ‘

Sorry. All fields are required.

’;
} else {

$fp = fopen($file,“a”);
$date = date(“d-m-Y H:i:s”);

fwrite($fp, ’


Date: '.$date.'
Name: '.$name.'
Email: '.$email.'
Website: '.$site.'
Message: '.$msg.'
');

fclose($fp);

echo ‘

Thank you ‘.$name.’ for singing the guestbook!

’;
}
?>

Back to guestbook

[/php]

I gave up on this one. And now I use http://www.jemjabella.co.uk/scripts/bellabook/. It’s incredible. So no need to reply to this post. However I have a cookie issue with the BellaBook, so I’ll make a new post for that.

Sponsor our Newsletter | Privacy Policy | Terms of Service