Love2c0de Posted September 7, 2013 Share Posted September 7, 2013 Good morning, I am doing a domain checker part to a site and researched a little. Found gethostbyname() function and noticed that if a domain exists for example www.google.com, it returns the IP address, and when one doesn't exists for example www.googledsahtggdfg.com, it returns the string entered. I know I could write code to check the string value and work out whether it is in use or available but need some more advice. Is this sufficient checking for whether a domain is available or is there further things I should be looking at? Thank you for your time. Kind regards, L2c. Quote Link to comment Share on other sites More sharing options...
Irate Posted September 7, 2013 Share Posted September 7, 2013 (edited) There are some interesting anecdotes on this found on the official manual page here, and it suggests you do not use gethostbyname in productive scripts. Otherwise, check against the first character of the return value. $host = gethostbyname("http://www.google.com");Edit: Code tag messed up. Edited September 7, 2013 by Irate Quote Link to comment Share on other sites More sharing options...
kicken Posted September 8, 2013 Share Posted September 8, 2013 Is this sufficient checking for whether a domain is available or is there further things I should be looking at? No, just because a domain doesn't resolve to an IP does not mean that it is available. Someone may have it registered but not pointing to anything (or only subdomains point to something). In order to check if a domain is available you need to do a whois check and see if it comes back as registered or not. Quote Link to comment Share on other sites More sharing options...
Love2c0de Posted September 8, 2013 Author Share Posted September 8, 2013 (edited) Good morning, I checked on my host and it has a WHOIS page where you can check domains. I noticed at the very bottom of the return value it says this: NOTE: THE WHOIS DATABASE IS A CONTACT DATABASE ONLY. LACK OF A DOMAINRECORD DOES NOT SIGNIFY DOMAIN AVAILABILITY. I also remember I asked about hashing passwords on here and was told to use an existing package such as PHPass. Is this one of those occasions where it would be better to use something already available. Looking into a few various pages from google, seems quite a task. Kind regards, L2c. Edited September 8, 2013 by Love2c0de Quote Link to comment Share on other sites More sharing options...
cataiin Posted September 8, 2013 Share Posted September 8, 2013 http://php.net/manual/en/function.checkdnsrr.php Quote Link to comment Share on other sites More sharing options...
vinny42 Posted September 8, 2013 Share Posted September 8, 2013 Also, remember that quite a few domains are parked, which means they will resolve but could still be available. Is this one of those occasions where it would be better to use something already available. Absolutely, although it is sadly also common practice for websites who offer these lookup-tools to register every domainname that comes up as available, so by the time you want to register it, it's suddenly taken and for sale... Quote Link to comment Share on other sites More sharing options...
Love2c0de Posted September 8, 2013 Author Share Posted September 8, 2013 Good evening, Just gone through the replies again. Is checking both checkdnsrr() and gethostbyname() in conjunction with each other a sufficient way to check availability? I'd rather not use an already available package but rather try it myself. Just looking for anything extra which has not been covered? Not 100% sure on how to use the WHOIS application within my own website. Kind regards, L2c. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.