Jump to content

Checking if a domain is in use.


Love2c0de

Recommended Posts

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.

Link to comment
https://forums.phpfreaks.com/topic/281963-checking-if-a-domain-is-in-use/
Share on other sites

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.
  On 9/7/2013 at 11:17 PM, Love2c0de said:

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.

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.

Also, remember that quite a few domains are parked, which means they will resolve but could still be available.

 

 

 

  Quote

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...

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.