The logic provided her prevents duplicate entries on page refresh using the browser refresh button
But If the user is inputting same data again and again and saving then this logic cannot do anything.
You will have to check whether entries exists before inserting