1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

How to make a php script to check domain name.

Discussion in 'PHP' started by mojjammal, Jan 3, 2014.

  1. #1
    Hi,
    I need help , do anybody knows how to make a php script to check domain name available for domain registration.
    I mean i am making a website where i want a box where people can check domain name for their domain registration and buy from same site like godaddy or namecheap.
    SEMrush
     
    mojjammal, Jan 3, 2014 IP
    SEMrush
  2. PoPSiCLe

    PoPSiCLe Illustrious Member

    Messages:
    4,623
    Likes Received:
    725
    Best Answers:
    152
    Trophy Points:
    470
    #2
    That is horrible, horrible code, mate...
     
    PoPSiCLe, Jan 4, 2014 IP
  3. SubediK

    SubediK Active Member

    Messages:
    63
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    83
    #3
    I feel like the code posted above would not work so well because @gethostbynamel will only get the ip of the domain and the code will assume that a domain is available if it cannot find the ip. But if a domain has been registered but hasn't been pointed to a ip (or is still propogating), it will say its available but it actually will not be. A lot of domains out there are registered but not used so don't rely on the code.

    If you want to get an accurate information on if a domain is available, you would either have to query the whois server of the domain and check if its available. If you don't want to search for domain whois providers individually, there are a lot of different free api's available out there that can check the whois servers for you. Check this stackoverflow.com/a/8693516

    So, in simple words, its not possible to accurately check if a domain is available with a couple
     
    SubediK, Jan 5, 2014 IP
  4. SubediK

    SubediK Active Member

    Messages:
    63
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    83
    #4
    *couple lines of code.
     
    SubediK, Jan 5, 2014 IP
    ROOFIS likes this.
  5. Alto Pluma

    Alto Pluma Member

    Messages:
    30
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    48
    #5
    Check out the following free PHP scripts to check domain names.

    http://www.adityasubawa.com/blog/post/56/domain-checker-with-php-script.html
    http://www.phpf1.com/product/domain-whois-script.html
    http://www.mrscripts.co.uk/index.php?op=proinfo
    http://www.particlesoft.net/particlewhois/
    http://www.cj-design.com/products/free-downloads/php-scripts/cjdomainwhois
     
    Alto Pluma, Jan 5, 2014 IP
  6. mojjammal

    mojjammal Active Member

    Messages:
    23
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    93
    #6
    Dear all,
    Thanks for all replays.
    But i want know how can i add a form in my website which can check a domain name is free for registration and complete registration process from same website. That mean how can i complete a domain registration from my website using any domain registrar company.
     
    mojjammal, Jan 8, 2014 IP
  7. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
  8. Boris1416

    Boris1416 Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    1
    #8
    I reccomended to you a CodeClerks сome and see for yourself)
     
    Boris1416, Apr 23, 2014 IP
  9. Boris1416

    Boris1416 Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    1
    #9
    I reccomended to you a
    ListingDock
    SeoClerk
    CodeClerks

    You will find there a lot of things, including the domain name) Come and see for yourself)
     
    Boris1416, Apr 23, 2014 IP
  10. KingJabeyt

    KingJabeyt Member

    Messages:
    60
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    38
    #10
    I really think I run into a script like this.. try and browse it in codebasket.com . they have handy scripts that you can use as well.
     
    KingJabeyt, May 7, 2014 IP
  11. Helge Sverre

    Helge Sverre Notable Member Affiliate Manager

    Messages:
    840
    Likes Received:
    99
    Best Answers:
    2
    Trophy Points:
    230
    Digital Goods:
    2
    #11
    Helge Sverre, May 8, 2014 IP
    ROOFIS likes this.
  12. ROOFIS

    ROOFIS Well-Known Member

    Messages:
    1,234
    Likes Received:
    30
    Best Answers:
    5
    Trophy Points:
    120
    #12


    I had a look at your class there, looks interesting and I might utilize it myself.

    Contrary to what most people say (including your blog entry) you can still minimise your API access limit's to various NIC's by using GetHostByName
    or dns_get_record taking advantage of the fact that most domain get pointed to a DNS for parking revenue or genuine website hosting.


    A simple boolean will solve the false positive by calling on an API to NIC's or scraping from public whois DB's thus limiting remote API calls (from about 60% to 80% or more) saving usage cost, limiting resources, etc.

    Below an example of a domain (articlebot.com) that's regged but not pointing to a DNS and indeed returns a false positive.

    
    $domain = "articlebot.com"; #domain only, no http:// www. etc...
    @$data = dns_get_record($domain);
    if (is_array($data)) {
        echo $domain." is already registered!! :(";
    } else {
        /* code here for API to NIC's or scrape query results from public whois DB's to avoid false positives */
         echo $domain." could be registered but not pointing to a DNS OR <b><u>maybe is available!:)</u></b>";
    }
    
    PHP:
    In this query the first condition fails and calls the second channel where you can make the API call.

    From experience I'd say about 6 to 8 out of 10 queries made the domain will be pointed to a parked page or website so API usage will indeed be reduced!;)




    .
     
    ROOFIS, May 13, 2014 IP
    Helge Sverre likes this.
  13. Helge Sverre

    Helge Sverre Notable Member Affiliate Manager

    Messages:
    840
    Likes Received:
    99
    Best Answers:
    2
    Trophy Points:
    230
    Digital Goods:
    2
    #13
    Ooooo that is actually quite a clever way to check!
    I might implement that into my class at some point :)
    Ty ^_^
     
    Helge Sverre, May 13, 2014 IP
    ROOFIS likes this.
  14. ROOFIS

    ROOFIS Well-Known Member

    Messages:
    1,234
    Likes Received:
    30
    Best Answers:
    5
    Trophy Points:
    120
    #14
    no prob's :):p
     
    ROOFIS, May 13, 2014 IP
  15. Abdul Ali Khan

    Abdul Ali Khan Member

    Messages:
    20
    Likes Received:
    0
    Best Answers:
    1
    Trophy Points:
    33
    #15
    This code is great but the only problem is that the is_array condition only checks if it's an array and even non-existent domains give an empty array (Array ()) so they get through the check. A better way would be to use this condition instead:

    if (empty($data)) {
        echo "The domain is available";
    } else {
        echo "The domain is not available";
    }
    PHP:
     
    Abdul Ali Khan, Jun 27, 2017 IP