Jump to content

comment refresh glitch. mutliply comments need help!


Minimeallolla

Recommended Posts

when i comment and reresh it resends the comment so i have done 2 comments and continues if i keep refreshing and just multiplies. how can i stop the fetch or while loop.

<?php 
  $query = ("SELECT * FROM homecomments");
$result = mysql_query($query);
while($row = mysql_fetch_assoc($result))
{
echo "<b>";
echo $row['username'] . "</b>: <Br> ";
   echo htmlentities($row['comment'], ENT_QUOTES, "UTF-8");
echo "<p>";
}
?>

thats my echo comment code. would it ahve anything to do with that?

Link to comment
Share on other sites

Refresh sends the data back to the page again.  That is why you get a pop up that ask "do you wish to resend the data". or thereabouts.

 

Three things you can do.

 

1. Re-direct the page to itself after the database insertion.  This clears the data out of the headers, so on refresh it will not send the data back to the page.

 

2. Set a session variable that limits the amount of time between comments. This agitates the user, and they usually don't sit there and wait for the timer to run out.

 

3. Check the comment against the last one the user supplied to the database, if it is the same, deny it.  This creates and extra query to the database.

 

The first one is the most logical, although it creates more server load.  On a system that isn't seeing 100's of pages an hour, it is no big deal.  This is the way that dreamweaver deals with the problem.

 

And no, the echo loop has nothing to do with it.  It is the insertion code you are dealing with.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.