Results 1 to 5 of 5
  1. #1

    Validating Domains In Different Ways ?

    Folks,

    When a user inputs his domain name (just the domain name. Eg. devshed.com) into my form field, I want the form to check if the domain is valid.

    1. I don't care if the inserted domain is registered or not. Nor care if it is functional or not. Aslong as it is a valid domain then that should be accepted.

    2. This time, I need to make sure the domain is registered and functional.


    I am spoilt for choice as too many code samples presented here:

    https://stackoverflow.com/questions/...in-name-in-php

    Which code sample from the above link would you use to satisfy my question number 1 and why particularly that one and not the others ?
    And, which one would you use to satisfy my question number 2 and why particularly that one over the others ?

  2. #2

    Validating Domains In Different Ways ?

    No ideas, anyone ?

  3. #3

    Validating Domains In Different Ways ?

    If you need to check just if a domain is valid, you can use regular expressions, as per your link with example.

    If you need to check if a domain is registered, use dns_get_record() function. It will return an array with DNS records if domain is OK, or false on error.

  4. #4

    Validating Domains In Different Ways ?

    For validation (of a whole lot of stuff including URL's and email addresses) you can't go past PHP's built in filter_var()function. Use that and it will make your life a whole lot easier.

  5. #5

    Validating Domains In Different Ways ?

    Yes, except that using built-in validation will not work in this case.

    FILTER_VALIDATE_URL will validate URLCode:
    http://localhost

    (which is NOT a domain), and will failCode:
    http://voveraitė.lt

    (which is a valid and working domain).

    Comments on this post

    • UniqueIdeaMan agrees




Posting Permissions

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