/    Sign up×
Community /Pin to ProfileBookmark

Detecting duplicate phone numbers

Hello

I am developing an application where user can enter their phone numbers. The phone numbers can be of any country, may/may not have country code in it. Can start with + or 0 and can be of any length.

The challenge for me to make sure that there are no duplicate phone numbers in the database. I need your help in this. Because if there are 2 same numbers but with different country codes then they should NOT be treated as same.

For example the following two numbers are same but with different country codes:
+919988776655
+4049988776655

Can someone help me?

PS: I m using PHP/MySQL

PPS: For some reason I cannot add a country code dropdown box separately.

Thanks

to post a comment
PHP

6 Comments(s)

Copy linkTweet thisAlerts:
@NogDogMar 18.2015 — If you want the country code and phone number in separate columns, then you can define a unique index across both columns in order to enforce it at the DB level:
<i>
</i>CREATE UNIQUE INDEX unique_phone_ix ON your_table_name(country_code, phone_number);
Copy linkTweet thisAlerts:
@NogDogMar 18.2015 — PS: If you are storing them in one column, if the "+" is not required, then I would strip it out before putting it in the DB in order to keep the data as similar as possible.
Copy linkTweet thisAlerts:
@rootMar 20.2015 — Ummm, different country codes means that they are two different phone numbers, it does not mean that the numbers are the same, they are different countries therefore different phones! Also, telephone numbering systems differ from country to country with differing number systems.
Copy linkTweet thisAlerts:
@phantom007authorMar 30.2015 — HI guys,

Not sure if I am following you.

What if a user enters

[B][B]+81-123456[/B][/B]

and other user enters

[B]+811-23456[/B]

if you strip off + and - symbols from the numbers, then both are the same.

Thoughts?


Thanks
Copy linkTweet thisAlerts:
@NogDogMar 30.2015 — [url=http://php.net/preg_replace]preg_replace()[/url]
Copy linkTweet thisAlerts:
@rootMar 30.2015 — If you wan someone to build this for your, then you will need to ask in the paid section, agree a price and hopefully all going well, you get what you want instantly and pain free.
×

Success!

Help @phantom007 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...