Ah, a problem I had myself, therefore I'll try and help you along the way.
I use cookie or session variable holding a random value (in my case, the date and time)
There are several ways around this and here is my effort
Set a random number on the post page in a hidden field,
when submitted, import this post/get variable, where you make your database call, surround it with an if condition. On initial viewing:
if session's random number does not equal posted random number , make the database call then set the session variable to equal posted random number.
next time page is refreshed, the database call will not happen, because session random number is equal to posted random number.
Thats the theory. You do the coding.
Other ways i have heard would be to make an extra expensive database call, and double check if this new message id has already been stored.
Or, when people no longer scorn on iframes, have an iframe offscreen which the form targets, and use that to make the database calls, that offscreen iframe could never be refreshed.
hope that is some help.