I suggest creating a unique key on your desk, rather than doing what you described. This way you avoid duplicating content no matter how many users are using your application at the same time. Your solution will not work if A inserts something, B inserts something else, then A sends again.
An example of adding a unique key to an existing table:
ALTER TABLE posting add UNIQUE KEY uk_posting (title, price, city)
Replace title, price, city combination of fields, which should be unique. Then all you have to do is handle the insert error.
source share