Reputation: 2468
In my app i'm passing my all contacts to my server to verify if given number is registered or not.
Issue is number can be saved in any of following manner
+91 9619
9619
09619
Basically all are same, where should I do the validation on my php script or in native, if in native, how?
Guidance needed , Thanks
Upvotes: 0
Views: 156
Reputation: 7
In your db query write like this
String combination1="original number"
String combination2="remove first digit in original number"
String combination3="remove first 2 digits in original number"
Query:
select count(*)
from table_name
where phoneNumer="combination1" or phoneNumer="combination2" or phoneNumer="combination3"
Example: If you pass 0997568474 the query is like this
select count(*)
from table_name
where phoneNumer="0997568474" or phoneNumer="997568474" or phoneNumer="97568474"
if count is greater than zero that means phone number existed...
Upvotes: 0
Reputation: 4869
Use only last 10 digits 9619****** while searching for numbers ...
Eg : if +91 9619123456 is already registered and 9619123456 or 09619123456 is sent to server last 10 digits of all 3 number are same so the will be verified as register ..
Use substr($my_string, -10) to get last 10 digits of phone number
Upvotes: 1