How do I impliment a hidden field in a post form so users can't accidentally double post? (PHP/Mysql
Posted
by ggfan
on Stack Overflow
See other posts from Stack Overflow
or by ggfan
Published on 2010-04-17T02:27:04Z
Indexed on
2010/04/17
2:33 UTC
Read the original article
Hit count: 314
When users submit a form, they will sometimes click refresh or backspace then resubmit which causes multiple entries in mysql. How can i prevent mysql from allowing more than 1 of the same entry? People suggested a hidden field with a value, but how do I use that?
<label for="state" class="styled">State:</label>
<input type="text" id="state" name="state" value="<?php if (!empty($state)) echo $state;
?>" size="30" /><br />
//a hidden field of a certain value?
________________________________________
<input type="submit" value="Post Ad!" name="submit" />
//php to insert to mysql
$query4 = "INSERT INTO posting (state) VALUES ('$state')";
mysqli_query($dbc, $query4);
© Stack Overflow or respective owner