jemjabella wrote in php 🤔curious

help with guestbook 'script'?

Hi.. been a member for a little while, not posted before though because I'm very much a 'n00b' to PHP and didn't have anything constructive to say. I need some help now though, if anyone would be so kind..

Basically, I recently set up a very basic guestbook - user posts an entry, entry + details is taken from $_POST and converted to variables, which are then stored in an 'entries.php' file which is included back into the index. The problem is, because I use the append thingy to write to the file, when the file is closed the focus/cursor/whatever is left at the bottom of the file. This means that each new entry is added to the bottom, so entries are displayed in reverse order.

What I want to do is have the entries added to the top of the file so they're displayed in the correct order. I've searched php.net and all I could find was rewind and fseek - so I've tried re-opening the file after I closed it and using the rewind and fseek things to reset the position to the very top, and it didn't work - either I was using the wrong thing or not doing something right.

Anyway.. I was wondering if there was something I was missing that could do this thing for me, without me having to resort to using a mySQL database or something.

URL: http://www.jemjabella.co.uk/gb

If you want the code, let me know.