Forum Moderators: coopster
Now my problem is that: after his clicking the submit, the user click the "Refresh". Then if he select the "Retry" in the IE warning window, the message will be inserted to the database again.
Is there any method or function that can clear or reset the value of autoglobal like $_POST['submit']?
Thanks a lot.
// connect to database
// ......
<?php
echo "submitButton = ".$_POST['submit']."<br><br>";
if($_POST['submit'])
{
$msg = $_POST['message'];
$sql = "INSERT INTO db_msg (msgText) VALUES ('$msg')";
mysql_query($sql);
}
else
{
?>
<form action="<?php $_SERVER['PHP_SELF']?>" method="post" name="form1">
<input name="message" type="text">
<input name="submit" type="submit" value="submit">
</form>
<?php
}
?>
there are some posts about already in this forum:
Allowing people to click a button only once? [webmasterworld.com] (javascript solution)
Users who keep hitting submit [webmasterworld.com] (discussion about the prob)
you can even create a session and the cross-check if the form has been submitted
-or-
you can place a key into the form (hidden, a random number or string) which will be inserted with the message text into you database after checking if this key does not exists. keep in mind that you need a unique key for this. check the php manual for unique id or similar, there is a function to create such a value.
- hakre