Page 1 of 1

A problem with my simple comment system

Posted: Sat Oct 03, 2009 6:55 am
by tehhparadox
Hi guys

I made this simple comment system, where people could just write in their name and comment and leave a message that everyone can see.

I've got a form set up with the fields name and comment, and I have a text file to store all the past comments (not database!).

Anyway, my program opens this txt file with fopen() append, and writes to it with fputs(). The only problem is, whenever people refresh the page after they left the comment, the browser sends the typed info again to the form, and the comment appear again. Can you do something to prevent this? I'll appreciate any help.

thanks

Re: A problem with my simple comment system

Posted: Sat Oct 03, 2009 8:35 am
by Darhazer
You have to redirect the user with header('Location: ...') after he puts the comment, in order to dispatch the POST data, and to allow them to refresh without reposting.

Re: A problem with my simple comment system

Posted: Sat Oct 03, 2009 10:02 am
by tehhparadox
Thanks Darhazer! you solved my problem.