refesh error [Guestbook in PHP]

liunx

Guest
I have a guestbook in PHP. When I've posted a message and then refresh the page (F5 in IE) I get an error.

<!-- m --><a class="postlink" href="http://www.secretsound.f2s.com/newsgroup.php">http://www.secretsound.f2s.com/newsgroup.php</a><!-- m -->

The page cannot be refeshed without resending the information. Click Retry to send the information again, Click cancel to view the page taht you were tryring to view.

how can I fix this problem?

TIA,That is not really an error. Its a standard alert message. Unlike HTML pages that reside on the server, pages that are created dynamically by scripts (PHP, PERL, etc) are not stored on the server, so when the refresh button or refresh command is initiated, the data from the form must be resent so that the page you want to see can be recreated by the script. Depending on how the script works, even if you click cancel you may still see the same page that you would if you clicked retry.

I don't know of a way to prevent the alert box from displaying during a refresh, but what I do is code a reload/refresh button on the form (which is just a submit button with a different name) that acts the same as when you first initiate the script.

<INPUT TYPE=submit NAME=reload VALUE="Refresh Page">

When the script recieves the data from the name/value pair (name=reload value=Refresh Page) it acts the same as if the script has been called by the URL that initially opens and runs the script.

Another thing to do is seperate the input form from the guestbook entries completely, like this forum. You read messages on a different page than the input form is on.

If you can't edit your PHP script and form then you may have to live with this "problem". Maybe someone else will know something.

Another way to circumvent this problem, and its not very elegant, is to have the script write the data which will be displayed (the form and guestbook entries) directly to an HTML file. This way you can have the form and the guestbook entries on the same page and it eliminates the refresh problem. The script opens the HTML file and appends new entries directly into the HTML file instead of into a seperate data file.

Regards,
Kevin
 
Back
Top