I have a site where the user enters in a "item". It is then stored. They can then view it and edit it etc. I don't want them to be able to add in the same item twice, e.g. "apples". I was thinking of when the submit the form checking it by selecting the row with the same name as $_POST['item_name'] and if it didn't return any rows then allow the script to continue. If it did return a row then terminate the script. Is this the best way of doing it or is there a better and easier way?
And that won't work if there are several users, and the block is meant to be pr. user, not pr. item. Depends on the needs. If you just need to check pr. user, do a SELECT-statement where you check for the content of item-name, and if it exists, you can maybe give the user the opportunity to directly update that entry, instead of storing a new entry.
This wouldn't work for my users. If user A enters "apples" user B can't then add "apples". I want only the user to be not allowed enter the same thing twice. I don't care if two different users add the same item.