tags:

views:

69

answers:

3

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);
+1  A: 

This was just asked yesterday

Michael Mrozek
great, thanks alot!
ggfan
+1  A: 

Relying on a client side validation is poor form. Do any checks server side and redirect the user appropriately.

Josh K
+2  A: 

You can use this after insert query.

$query4 = "INSERT INTO posting (state) VALUES ('$state')"; mysqli_query($dbc, $query4);

header("Location: yourpage.php");

Kanak Vaghela