PHP

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.

But if you want to make your own web site to check the availability of domain name then  here is the very simple and friendly script below you can make your own domain checker tool on your web site. So friends please find below Domain availability checker script in PHP

<?php
<h2>Check Domain Availability</h2>

<form action="" method=post>
<table>
<tr>
<td>Enter Domain Name:</td>
<td> : <input type="text" name="domain_name"></td>
<td>
<select name="suffix">
<option value=".com">.com</option>
<option value=".in">.in</option>
<option value=".co.in">.co.in</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=".co.id">.co.id</option>
<option value=".or.id">.or.id</option>
<option value=".go.id">.go.id</option>
<option value=".sch.id">.sch.id</option>
<option value=".ac.id">.ac.id</option>
<option value=".mil.id">.mil.id</option>
<option value=".web.id">.web.id</option>
<option value=".tv">.tv</option>
<option value=".cn">.cn</option>
<option value=".cc">.cc</option>
</select>

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

<?php

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);
 if(empty($response)){
 echo "<H2 style='color:green;' >Domain $name_domain is available.</H2>";

 }else{
 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, If you see in loop whole please let me know through comment box, thanks…

Comments (24)

  1. 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. Hi,
    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. 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. this is good code for helping me

    thank s

  5. 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. 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. 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. Great stuff, thanks

  10. 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. 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. Thanks Ajit Tiwari,
    You are great !!!!
    You give me the solutions for my 7 day google search

  15. how do i get possible domain name suggestions

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

  17. Always show Domain is available even I search any random text.

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

  19. Thank you, sir. You solved my Problem

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

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

    • please i need to know il the script have request limit for whois, for example, how many request per day or per month ?

      thank you for your help

  22. Thanks for a great php script but i have a problem. Page not refreshed.

  23. You made things just work here. Our local domains can not be registered without DNS so this is 100% fine.

Comment here