zq29 Posted April 20, 2006 Share Posted April 20, 2006 I have a script where I allow a user to add, edit or delete information from a database. I normally have three seperate sets of pages for each function, i.e. the form on one page, and the processing on another. In an attempt to make things cleaner I am integrating all of the scripts into one. My only problem is, if a user should decide to click refresh (for what ever reason) after perviously adding some info to the database, the info is added again, and again on any further refresh. Does anyone know of a method to prevent this, maybe by clearing the variables from the browser cache or something? - I don't know how this works technically at a browser level...Heres a demo script to give you an idea of the kinda script I have:[code]<?phpif(isset($_POST['submit'])) { mysql_query("INSERT INTO `table` (`name`) VALUES ('$_POST[name]')");}?><form name="add" action="" method="post"> <input type="text" name="name"/> <input type="submit" name="submit" value="Insert"/></form>[/code] Quote Link to comment Share on other sites More sharing options...
wisewood Posted April 20, 2006 Share Posted April 20, 2006 Something along the lines of...// Get the last row from the table before entering the new one.SELECT * FROM table ORDER BY (unique id number field) DESC LIMIT 1// Compare the content with the variables you've just submittedif($db_variable=="$_POST[variable]"){// dont enter into the database}else{// DO ENTER into the database} Quote Link to comment Share on other sites More sharing options...
zq29 Posted April 20, 2006 Author Share Posted April 20, 2006 Sounds like that should be sufficient, thanks for that! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.