Domain availability checker script in PHP

Hello friend,

When we think to own a domain then first we need to check that particular domain is available or not. Many domain registration and web hosting service provider  company provide the facility to check domain availability on their official web site.

Here are the script below you can make your own domain checker tool on your web site.

<h2>Check Domain Availability</h2>

<form action="" method=post>
<td>Enter Domain Name:</td>
<td> : <input type="text" name="domain_name"></td>
<select name="suffix">
<option value=".com">.com</option>
<option value=".in">.in</option>
<option value=""></option>
<option value=".net">.net</option>
<option value=".org">.org</option>
<option value=".biz">.biz</option>
<option value=".info">.info</option>
<option value=".mobi">.mobi</option>
<option value=".ws">.ws</option>
<option value=""></option>
<option value=""></option>
<option value=""></option>
<option value=""></option>
<option value=""></option>
<option value=""></option>
<option value=""></option>
<option value=".tv">.tv</option>
<option value=".cn">.cn</option>
<option value=".cc">.cc</option>

<td align="right" colspan="3"><input type="submit" name="check" value="Check"></td>


if(isset($_POST['check'])) {

 if (!empty($_POST['domain_name'])){
 $name_domain = trim($_POST['domain_name']).$_POST['suffix'];
 $response = @dns_get_record($name_domain, DNS_ALL);
 echo "<H2 style='color:green;' >Domain $name_domain is available.</H2>";

 echo "<H2 style='color:red;'>Domain $name_domain has taken.</H2>";
 else {
 echo "<H2 style='color:red;'>Error: Domain name can not be left empty.</H2>";

Please let me know if you have any doubt or feedback, thanks…

Tagged , , . Bookmark the permalink.

20 Responses to Domain availability checker script in PHP

  1. Vanquish Magazine says:

    I have learn some just right stuff here. Certainly worth bookmarking for revisiting. I wonder how much effort you set to create this kind of excellent informative site.

  2. Max Wolf says:

    first, thank you so much for your great effort. WELL DONE!
    I’ve tried this script on the local wamp server it works very well, but when I tried to use it in my remote server it is always giving me that the domain name is taken. Really I don’t know what’s the problem.
    I’m looking forward to your valued help.
    Thank you so much.

  3. Ajit Tiwari says:

    Hello Max,
    But I am not facing any such type of issue, can you elaborate more or provide me URL where I can check the same. Thanks,

  4. raj says:

    this is good code for helping me

    thank s

  5. Bilal says:

    I edit the php code and after that I was testing and I found out that sometimes when domain check button is clicked it redirects to adult sites. What do I do now?

  6. Bilal says:

    This code shows domain available for premium domains as well. What is the code if premium domains are entered it shows “This is premium domain name”?

  7. Hello,
    Recently I am using gethostbyname which slowdown my processing speed, is this will be effective for process speed???

  8. FMR says:

    I don’t know if it’s because it’s late and I’m tired but no matter what I try, no matter what domain name I input, I always get “domain name is taken”. As though dns_get_record is not responding or something. I used the code as is. When I leave the field blank I get the error message.

    Does anyone have any ideas what might be the problem?
    My brain?

  9. senki geza says:

    Great stuff, thanks

  10. Mahendra says:

    Hi bro,

    I am just trying to use your code on my website ..but there is error ”
    Parse error: syntax error, unexpected ‘if’ (T_IF) in C:\xampp\htdocs\nha\a.php on line 42

    can you please check ….. ???
    waiting for your reply here..

  11. Bp singh says:

    i am very thankful to use this code

  12. I have published my own code now.
    It is available on my blog here: PHP Domain Availability Checker Script.

    Way better code than this.

  13. Code is working without error but result is not true.

  14. ANVAR SADIQ says:

    Thanks Ajit Tiwari,
    You are great !!!!
    You give me the solutions for my 7 day google search

  15. joshua says:

    how do i get possible domain name suggestions

  16. Abir says:

    Thank You So Much @Ajit Tiwari 🙂
    Code is working without error and result is true

  17. DNS is not reliable. A domain name can be registered without a DNS record. Whois is will give you a more reliable information. You can use this Whois API to do so. The PHP client would be whois-api-php.

  18. rakesh says:

    Thank you, sir. You solved my Problem

  19. Prabal Bhadra says:

    Hi when i copy the code and paste to my local xampp server and run the script it shows:

    Parse error: syntax error, unexpected ‘<', expecting end of file in E:xampphtdocsdomainnew.php on line 2

  20. nemmer says:

    this is work fine, but is have a limite for whois request ?

Leave a Reply

Your email address will not be published. Required fields are marked *