JSHINER Posted March 6, 2007 Share Posted March 6, 2007 I currently have the following: $zip = $db->escape($_GET['zip']); $db->query("INSERT INTO zipdata SET zips = '$zip'"); However, every time that page loads it is inserted. Is there a way to make it only insert one time per user. Link to comment https://forums.phpfreaks.com/topic/41363-inserting-data-only-once/ Share on other sites More sharing options...
JBS103 Posted March 6, 2007 Share Posted March 6, 2007 Use a Select query to check if the zip is already there. If it is, then don't add it. If it isn't, send it through. Thats one method at least, assuming that the $zip would be the same each time the page is refreshed. Link to comment https://forums.phpfreaks.com/topic/41363-inserting-data-only-once/#findComment-200410 Share on other sites More sharing options...
JSHINER Posted March 6, 2007 Author Share Posted March 6, 2007 $zip is different every time - and I dont mind if it's added more than once. However, I dont want the same user refreshing a page or going to a page 10 times and it being added 10 times. Link to comment https://forums.phpfreaks.com/topic/41363-inserting-data-only-once/#findComment-200412 Share on other sites More sharing options...
Barand Posted March 6, 2007 Share Posted March 6, 2007 or set a unique key on zipdata(user, zips) Link to comment https://forums.phpfreaks.com/topic/41363-inserting-data-only-once/#findComment-200414 Share on other sites More sharing options...
JSHINER Posted March 6, 2007 Author Share Posted March 6, 2007 How is the user identified ? Link to comment https://forums.phpfreaks.com/topic/41363-inserting-data-only-once/#findComment-200416 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.