If its a potentially long message you're storing, you can always create an MD5 sum during insertion, compare it to existing MD5 sums, and if they don't match, there's not duplicates. Just as an example, if you're inserting message and user data, first see if there's duplicates: if (!mysql_num_rows(mysql_query("select count(*) from table where stored_sum = md5(".$message.$user.")"))) { // if it's not already there, store it. mysql_query("insert into table message = '$message', 'user' = '$user', message_sum = md5(".$message.$user.")"); } else { echo "Duplicate!"; } hth, -Micah On Monday 01 August 2005 12:56 pm, Hallvard wrote: > Thanks! > > I had already dealt with the problem using unique key, as many others > suggested. However, the records (post your comment-type) doesn't have any > natural key, so I had to concotinate several long text strings, which isn't > nice. > > Could you point me in the direction of any code examples for this? > > "Alexander Veremyev" <alexander.v@xxxxxxxx> wrote in message > news:42EBAFA9.7030409@xxxxxxxxxxx > > > You could use next simple rules to avoid this problem: > > > > 1. Never change anything in your storage (database) by GET HTTP request > > method. > > 2. Never prepare any Web page by POST method. > > 3. After Form is processed (with a POST method) use HTTP redirect to > > corresponding GET page which should produce a result of processing. (it > > may be the same php script) > > > > So you will have "getters" and "setters" for your Web application. > > Only "getters" will be stored in a browser history in this case and users > > will be able to use back/forward/reload browser functionality without any > > side effects (also without requests to post data again). > > > > > > PS Furthermore, such use of GET and POST methods corresponds to their > > description in HTTP RFC's > > > > > > With best regards, > > Alexander Veremyev. > > > > Hallvard wrote: > >> I have a page that posts data from a form to a mysql database. > >> > >> The problem is that if the user hits the reload button on the browser, > >> the data will be posted again, resulting in a duplicate record. > >> > >> How can I avoid that? -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php