Jump to content

Preventing Duplicate Entries


jimfog

Recommended Posts

Suppose a user enters his/her name in the db. The same user goes to do that twice, something i want to prevent since i do not want duplicate entries in my database. What i code i will have to write to prevent the above? Obviously i will have to check the database first to see if the user already exists there(IF statement). It should be straightforward-i need little help with the code. Some php statements must be required that will run the queries. Obviously, in the end, a message will inform the user that similar data exist in the database. The above scenario is typical in the web-i am a beginner though and require some assistance. Thanks.

Link to comment
Share on other sites

You need to use a select query to look up the user, and you can use mysql_num_rows to see how many records the query returned. If it returned 0 then it didn't match anything. Post the code you're working on if you have specific questions about it. You can also use a count query instead of mysql_num_rows. http://us.php.net/manual/en/function.mysql-num-rows.php

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...