Forum Moderators: coopster

Message Too Old, No Replies

Any way to reset autoglobal when refresh a form?

         

yf_wang

11:58 pm on Jul 15, 2003 (gmt 0)

10+ Year Member



As shown in the following simple form, if the user types a message in the textfield and click the submit button, the message will be inserted in the database.

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
}
?>

hakre

7:59 am on Jul 16, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



hi!

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

yf_wang

2:05 pm on Jul 16, 2003 (gmt 0)

10+ Year Member



Thanks, hakre.

Can we clear out the contents of $_POST?

hakre

4:16 pm on Jul 17, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



hi yf_wang,

i do not understand your last question (clear $_post). in generell you can, but why do you want to? please write a bit more.