FrankPorter
asked on
detect when F5 or submit
hi,
Please assist how can we stop or prevent the page from adding the same record that was previously added when the user hits F5.
PHP mysql -a sample code will help.
<?php
if(@$_POST['submit']=="add ")
{
$myQuery="insert into mytable (name) values( " . @$_POST['name'] . " )";
mysql_query($myQuery) or die(mysql_error());
}
<form name ="create" method="post">
<Input name="name" type="Text" <?php $_POST['name'] ?>>
<input name "submit type="submit" value="add">
</form>
Thanks.
Please assist how can we stop or prevent the page from adding the same record that was previously added when the user hits F5.
PHP mysql -a sample code will help.
<?php
if(@$_POST['submit']=="add
{
$myQuery="insert into mytable (name) values( " . @$_POST['name'] . " )";
mysql_query($myQuery) or die(mysql_error());
}
<form name ="create" method="post">
<Input name="name" type="Text" <?php $_POST['name'] ?>>
<input name "submit type="submit" value="add">
</form>
Thanks.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You can redirect to the "add" page as well.
ASKER
Is this the standard way of dealing F5 refresh scenario ? or there's a better way of handling..
Thanks.
Thanks.
It is a solution to the F5 "the page you are trying to load was submitted using POST Data" warning.
Alternatives to duplicate prevention also account for testing if data has been recently added to database, or tracking variables in sessions.
-r-
Alternatives to duplicate prevention also account for testing if data has been recently added to database, or tracking variables in sessions.
-r-
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
$show_form = false; << This one should be "true"; :$
Sorry for that ;)
Sorry for that ;)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
is there a standard way to do this rather than redirecting here and there?
Thanks.