Faks Posted October 12, 2010 Share Posted October 12, 2010 Here is video and there is shown how specific this problem is http://faksx.sytes.net/help/ Solutions Witch doesn't fit in for this time is meta refresh,header(),exit(),die() . Link to comment https://forums.phpfreaks.com/topic/215699-need-prevent-inserting-duplicate-record-in-datbase-when-refresh-form/ Share on other sites More sharing options...
New Coder Posted October 12, 2010 Share Posted October 12, 2010 I had a similar problem and I used an IF NOT EXISTS Query for mssql, the equivilent for mysql is INSERT IGNORE INTO Look these up they may help you Link to comment https://forums.phpfreaks.com/topic/215699-need-prevent-inserting-duplicate-record-in-datbase-when-refresh-form/#findComment-1121452 Share on other sites More sharing options...
Faks Posted October 12, 2010 Author Share Posted October 12, 2010 i would glad to see and example meanwhile i am going to do Link to comment https://forums.phpfreaks.com/topic/215699-need-prevent-inserting-duplicate-record-in-datbase-when-refresh-form/#findComment-1121460 Share on other sites More sharing options...
New Coder Posted October 12, 2010 Share Posted October 12, 2010 Looking at your video it would appear you are using mysql as on one of your tabs you have php myadmin open so I'm assuming you need ]# http://www.tutorialspoint.com/mysql/mysql-handling-duplicates.htm INSERT IGNORE INTO tbl_name (column1, column2) VALUES( 'val1', 'val2'); if the same items are then submitted for a second time the insert will not happen. I'm not a pro at mysql and these were actually suggested to me in another thread. but it did work for me. If you have trouble re-wrritting your actual insert query to use the insert ignore post it here and i'll help if I can. Link to comment https://forums.phpfreaks.com/topic/215699-need-prevent-inserting-duplicate-record-in-datbase-when-refresh-form/#findComment-1121476 Share on other sites More sharing options...
Faks Posted October 13, 2010 Author Share Posted October 13, 2010 Hi everybody i got code chuck of token but the main problem is it's not working i would really happy to fix it up . if(isset($_POST['token']) && $_POST['token'] == $_SESSION['token']){ //Add Comment unset($_SESSION['token']); } $new_token = md5(time() . rand(0,100)); $_SESSION['token'] = $new_token; ?> <form method="post" action=""> <!--lauki šeit--> <input type="hidden" name="token" value="<?=$new_token;?>"/> </form> Link to comment https://forums.phpfreaks.com/topic/215699-need-prevent-inserting-duplicate-record-in-datbase-when-refresh-form/#findComment-1121700 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.