Form duplicate post problem

From: Date: Sun, 29 Dec 2002 02:00:32 +0000
Subject: Form duplicate post problem
References: 1 2 3 4 5 6 7  Groups: php.general 
Request: Send a blank email to php-general+get-129557@lists.php.net to get a copy of this message
Hi, I am having some problems with duplicate form input. I have a form that adds comments to an article, works fine, but if the user clicks on "refresh", having added a comment previously, the same comment is added again. I tried clearing the variables after the database write, but the refresh somehow resends the previous values. Roughly, heres how my script works: (not using actual code syntax here) ------------------ if {$flag=1 AND $name!='' AND $commentbody!=''){ inserts the comment into the database $flag = 0 $name = '' $comment = '' } ------------------ routine to display the article and the existing comments here ------------------ form here if user clicks send, puts $flag=1 and calls same page ------------------ How can i prevent these double entries? Some command to definitely clear the variables? Thanks. Pag

« previous php.general (#129557) next »