Results 1 to 3 of 3

Thread: how to send sms using php script ?

  1. #1
    Join Date
    Apr 2010
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default how to send sms using php script ?

    i am looking for a phone number verification using php ?

  2. #2
    Join Date
    Jan 2007
    Location
    Davenport, Iowa
    Posts
    2,385
    Thanks
    100
    Thanked 113 Times in 111 Posts

    Default

    Forgive me if I am wrong, but this sounds like a homework assignment.

    I will say that you will need to use PCRE (Perl Compatible Regular Expressions) for this. In particular you need to use preg_match. I assume that what you are talking about is data submitted via form and you want to check to see if it is a valid phone number as opposed to something made up, similar to detecting whether the email a user submits is a valid email. You probably also want to be sure that the phone number is U.S. based or other.
    Last edited by james438; 04-29-2010 at 07:15 AM.
    To choose the lesser of two evils is still to choose evil. My personal site

  3. #3
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    It's fairly easy to do a few ways. I'm sure there's an answer out there on google. Using regex [regular expressions] (described above) is the shortest way to go, or you could just split the phone number at various parts. For example, the area code should be between 100 and 999, so just do that using basic math.

    The main problem with this is dealing with lots of varied user input:
    ###-###-#### or (###) ###-#### or ##########, etc.

    One way to do this is to pre-process the values: remove everything that is not a number.


    But what about international numbers? What about numbers without an area code? Not allowed? Treated differently?

    If you still remove everything that is not a number then you can check the length and go from there: if it's 7 numbers it's a local number; if it's 10 it's got the area code; if there's more, then you get an international number.

    But there are also problems with adding the "1" before something like "1-800" vs "800".

    Again, I'd just look on google....
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •