473,378 Members | 1,699 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

How to stop adding/updating duplicate username and email?

9
Hello,

I am creating a web application in which registrations are open as usual. My doubt is, if some one try to create an account by an email-id like 'foo@gmail.com', at same time other user also try to create account by same emailid 'foo@gmail.com', what will happen in this case? I have added a validation to check the duplicate email-id in the database before insert and update in my script but i am thinking if both request submitted on same time then what will happen? will PostgreSQL add both records into the table? Please suggest me how to handle such situations?

I heard that such type of problem can be prevent by row locking. Could you please help me to sort out it?

Mangal Kumar
Nov 15 '11 #1
3 3520
rski
700 Expert 512MB
Create a unique index or primary key on the email-id field and you will not have to check for duplicates, database will do it such validation for you. After inserting a row you can catch an exception and show user a message that such email already exists.
Nov 15 '11 #2
mangal
9
Thank you

I will try it.
Nov 18 '11 #3
rski, thanks a lot for your answer! i find it also pretty useful! Very good!


_________________
<link removed by moderator>
Aug 22 '12 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Mohammed Mazid | last post by:
Hi, Basically I have a problem with registering to my quiz system. I had borrowed some code from an existing program but I just do not know why it doesn't work. If (txtUsername = "" Or...
6
by: 6thirty | last post by:
Hi, I've created a stocktaking database using Access XP. This is indexed by two fields - part number and shelf location. I am currently inputting all the data via a form. When I have entered a...
2
by: ibiza | last post by:
Hi all, I have a CreateUserWizard with two steps, one to create the user, and the other to associate roles to him. When I try to insert a user with a username that already exists, I can't create...
0
by: AJang | last post by:
I write a windows form application. In this application, I perform some operation on each file of a directory. For monitoring , I update one TextBox control's Text with the filename which is being...
2
by: smartchap009 | last post by:
hi, If i can get help in writing perl code for adding updating and deleting user in linux.adds a user to the database file called passwd. With the -a switch the program accepts a user-id and...
1
by: smartchap009 | last post by:
Adding,Updating and Deleting user using perl script in linux -------------------------------------------------------------------------------- hi, If i can get help in writing perl code for...
1
by: yevgenia | last post by:
Hi there, I am developing an application in Access 2003 and need to send an email through Outlook based on the information entered on the form. Everything works except that the email is being sent...
2
by: Martin Eckart | last post by:
Hello, I have built a Hello World Web Service using Visual Studio 2005 and .NET 2.0 on machine A. Setting up a Web Site on machine B and adding a web reference to that WS works fine, without any...
10
by: tan | last post by:
Hi, I have tested my databse and everthing works fine but then have given it to a customer and the following part of the code does not seems to be updating as required. Set rs =...
0
by: Simon429 | last post by:
Hi, I got this really annoying problem. When I add a crystal report viewer into my asp.net Form, it automatically added duplicate assembly in my web.config as follows: <add...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.