Re: [PHP] Checking Phone Numbers
Well, in my context where this is an application to apply to a community college, I think I can safely exclude non-us phone numbers. :-) The code that Robert supplied seems to work just great. Thanks. -- Kevin Murphy Webmaster: Information and Marketing Services Western Nevada College www.wnc.edu 775-445-3326 On Jun 14, 2007, at 10:25 AM, Daniel Brown wrote: On 6/14/07, Edward Kay <[EMAIL PROTECTED]> wrote: > -Original Message- > From: Kevin Murphy [mailto:[EMAIL PROTECTED] > Sent: 14 June 2007 16:38 > To: php > Subject: [PHP] Checking Phone Numbers > > > I collect phone numbers via a web form that breaks the phone number > up into 3 parts (3-digit area, 3-digit prefix, etc). Occasionally, I > am having people put in a phone number such as 999-999- or > 000-000- or other numbers that are all the same. How would I go > about comparing those three fields to see if they are all the same > numbers. I can't just exclude it anytime that the numbers all match, > for example 444 is a valid area code. It should only fail if all the > numbers are exactly the same. > > All the processes I've come up with seem to be rather convoluted. Is > there a simple way to test for this? > > -- > Kevin Murphy > Webmaster: Information and Marketing Services > Western Nevada College > www.wnc.edu > 775-445-3326 Whilst there are several ways to do this, it's not going to make someone entering dummy data give you their real phone number. They'll just enter another one that bypasses your check, e.g. 111-222- or 321-321-4321. I'd also caution about forcing any specific format on telephone numbers. I'm in the UK and our phone numbers are in the format -xxx-, xxx-- or x-xx. This would not work with your form. If people are happy to give you their number, let them type it how it is. It could even include other characters, e.g. +44 (0)1234 567890 ex 324 Edward -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php My suggestion is that we require the United Kingdom and other countries around the world to conform to our standards of telephone numbers. After all, isn't that what we do in America; change the world to meet our expectations or choose to shun them for not doing so? Nevermind that would go far beyond list topics and wy too far into the realm of political dissent. -- Daniel P. Brown [office] (570-) 587-7080 Ext. 272 [mobile] (570-) 766-8107 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Checking Phone Numbers
On 6/14/07, Kevin Murphy <[EMAIL PROTECTED]> wrote: I collect phone numbers via a web form that breaks the phone number up into 3 parts (3-digit area, 3-digit prefix, etc). Occasionally, I am having people put in a phone number such as 999-999- or 000-000- or other numbers that are all the same. How would I go about comparing those three fields to see if they are all the same numbers. I can't just exclude it anytime that the numbers all match, for example 444 is a valid area code. It should only fail if all the numbers are exactly the same. All the processes I've come up with seem to be rather convoluted. Is there a simple way to test for this? -- Kevin Murphy Webmaster: Information and Marketing Services Western Nevada College www.wnc.edu 775-445-3326 Like others have said, there isn't much you can do about this. People are either going to give you their information or not. The only thing you can do is make sure there is a value that could possibly be a phone number for people who might have just forgot to input one. Otherwise you're going to just end up stepping on someone's toes who really means to do what they are doing. If you really need to validate the phone number then put a notice up saying US phone numbers only and give a very specific format that they must adhere to. This isn't really a good thing though seeing as the web is a global playground, but maybe you have your reasons. Now this mindset doesn't transition to other values. If you are expecting someones age and have the field Age (eg. 35) then you can check that with ctype_digit() and redisplay the form to them if the value does not pass. Another example is that on some forms I make email addresses are required so we can send them their order confirmation. I use a simple regex with a hostname lookup to see if the domain exists. Even with all that the user can always type [EMAIL PROTECTED] and it would pass perfectly. Just as an aside, validate data. Don't try to sanitize into something you want. What I mean is if you are asking for a credit card number don't do a preg_replace to strip out non-numbers. Instead do a preg_match() or ctype_digit() on numbers only and if it doesn't match exactly what you want, spit it back to the user and tell them to fix it. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Checking Phone Numbers
On 6/14/07, Edward Kay <[EMAIL PROTECTED]> wrote: > -Original Message- > From: Kevin Murphy [mailto:[EMAIL PROTECTED] > Sent: 14 June 2007 16:38 > To: php > Subject: [PHP] Checking Phone Numbers > > > I collect phone numbers via a web form that breaks the phone number > up into 3 parts (3-digit area, 3-digit prefix, etc). Occasionally, I > am having people put in a phone number such as 999-999- or > 000-000- or other numbers that are all the same. How would I go > about comparing those three fields to see if they are all the same > numbers. I can't just exclude it anytime that the numbers all match, > for example 444 is a valid area code. It should only fail if all the > numbers are exactly the same. > > All the processes I've come up with seem to be rather convoluted. Is > there a simple way to test for this? > > -- > Kevin Murphy > Webmaster: Information and Marketing Services > Western Nevada College > www.wnc.edu > 775-445-3326 Whilst there are several ways to do this, it's not going to make someone entering dummy data give you their real phone number. They'll just enter another one that bypasses your check, e.g. 111-222- or 321-321-4321. I'd also caution about forcing any specific format on telephone numbers. I'm in the UK and our phone numbers are in the format -xxx-, xxx-- or x-xx. This would not work with your form. If people are happy to give you their number, let them type it how it is. It could even include other characters, e.g. +44 (0)1234 567890 ex 324 Edward -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php My suggestion is that we require the United Kingdom and other countries around the world to conform to our standards of telephone numbers. After all, isn't that what we do in America; change the world to meet our expectations or choose to shun them for not doing so? Nevermind that would go far beyond list topics and wy too far into the realm of political dissent. -- Daniel P. Brown [office] (570-) 587-7080 Ext. 272 [mobile] (570-) 766-8107 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Checking Phone Numbers
> -Original Message- > From: Kevin Murphy [mailto:[EMAIL PROTECTED] > Sent: 14 June 2007 16:38 > To: php > Subject: [PHP] Checking Phone Numbers > > > I collect phone numbers via a web form that breaks the phone number > up into 3 parts (3-digit area, 3-digit prefix, etc). Occasionally, I > am having people put in a phone number such as 999-999- or > 000-000- or other numbers that are all the same. How would I go > about comparing those three fields to see if they are all the same > numbers. I can't just exclude it anytime that the numbers all match, > for example 444 is a valid area code. It should only fail if all the > numbers are exactly the same. > > All the processes I've come up with seem to be rather convoluted. Is > there a simple way to test for this? > > -- > Kevin Murphy > Webmaster: Information and Marketing Services > Western Nevada College > www.wnc.edu > 775-445-3326 Whilst there are several ways to do this, it's not going to make someone entering dummy data give you their real phone number. They'll just enter another one that bypasses your check, e.g. 111-222- or 321-321-4321. I'd also caution about forcing any specific format on telephone numbers. I'm in the UK and our phone numbers are in the format -xxx-, xxx-- or x-xx. This would not work with your form. If people are happy to give you their number, let them type it how it is. It could even include other characters, e.g. +44 (0)1234 567890 ex 324 Edward -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Checking Phone Numbers
On Thu, 2007-06-14 at 08:38 -0700, Kevin Murphy wrote: > I collect phone numbers via a web form that breaks the phone number > up into 3 parts (3-digit area, 3-digit prefix, etc). Occasionally, I > am having people put in a phone number such as 999-999- or > 000-000- or other numbers that are all the same. How would I go > about comparing those three fields to see if they are all the same > numbers. I can't just exclude it anytime that the numbers all match, > for example 444 is a valid area code. It should only fail if all the > numbers are exactly the same. > > All the processes I've come up with seem to be rather convoluted. Is > there a simple way to test for this? Cheers, Rob. -- .. | InterJinn Application Framework - http://www.interjinn.com | :: | An application and templating framework for PHP. Boasting | | a powerful, scalable system for accessing system services | | such as forms, properties, sessions, and caches. InterJinn | | also provides an extremely flexible architecture for | | creating re-usable components quickly and easily. | `' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Checking Phone Numbers
I collect phone numbers via a web form that breaks the phone number up into 3 parts (3-digit area, 3-digit prefix, etc). Occasionally, I am having people put in a phone number such as 999-999- or 000-000- or other numbers that are all the same. How would I go about comparing those three fields to see if they are all the same numbers. I can't just exclude it anytime that the numbers all match, for example 444 is a valid area code. It should only fail if all the numbers are exactly the same. All the processes I've come up with seem to be rather convoluted. Is there a simple way to test for this? -- Kevin Murphy Webmaster: Information and Marketing Services Western Nevada College www.wnc.edu 775-445-3326