jawinn Posted October 3, 2006 Share Posted October 3, 2006 I have a web form that dumps form data into a DB. One of the fields is for email address. I would really like the form to kick back an error message if an email address is used that is already in the DB. My DB only has one table. What would the code be for that?Thanks in advance,J Quote Link to comment Share on other sites More sharing options...
fenway Posted October 3, 2006 Share Posted October 3, 2006 There are lots of ways to handle this, depending on whether you can't have duplicates ever, or just do want to add new ones. You can simply query the table before and see if another matching entry is found, or you can strictly enforce it with an index. Quote Link to comment Share on other sites More sharing options...
jawinn Posted October 3, 2006 Author Share Posted October 3, 2006 This is an empty DB. I will be empting it weekly and eventually daily. I want to prevent ANY duplicates for a specific column. Quote Link to comment Share on other sites More sharing options...
fenway Posted October 3, 2006 Share Posted October 3, 2006 Then go with a UNIQUE index. Quote Link to comment Share on other sites More sharing options...
jawinn Posted October 3, 2006 Author Share Posted October 3, 2006 [quote author=fenway link=topic=110407.msg446343#msg446343 date=1159910890]Then go with a UNIQUE index.[/quote]How do I add that to my script? Quote Link to comment Share on other sites More sharing options...
fenway Posted October 4, 2006 Share Posted October 4, 2006 You have to modify your script to see if your INSERT failed. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.