PHP Domain Availability Checker Script (Check Domain Instantly)

How to check Domain is available? One is self-hosted PHP script and second is Domain provider website. Today we are sharing PHP Domain Availability Checker Script. Through the PHP script quickly and accurate results you will get it.

As we know, to create a new website, we need to first get the Domain name. And now a day almost all popular or related named domain has already registered. So it’s very difficult to get a selected name. Thus, we have to check the domain name is available or has already registered.

Many Domain registrations and Web hosting service provider companies provide facilities to check Domain availability on their website. But If you want to make your own tool to check the availability of domain name then here we share simply PHP script to make your own Domain checker tool. So let’s see Domain availability checker script in PHP.

Instantly Domain Availability Checker In PHP

This program created a form with HTML and CSS. In the form element we added <input type=”text”> field and added <button type="submit"> search button. When submitting the form it will call gethostbyname() PHP function. This function simply returns IPv4 address corresponding to a given Internet hostname. If entered domain name not available then this function returns IPv4 address. And if the domain name is available then this function returns the same domain name string. Finally, we check if condition and give a final result of Domain availability.

View DemoDownload Source

We have create domain-checker-tool.php files that include HTML, CSS, and PHP Codes.

<!DOCTYPE html>
<html lang="en">
    <head>
        <title>Instant PHP Domain Availability Checker Script</title>    
    </head>
    <body>
        <div class="wrapper">
            <h2>Check Domain Name Availability</h2>
            <div class="container">
                <form action="" method="GET">
                    <input id="searchBar" class="searchbar" type="text" name="domain" placeholder="Search domain name..." value="<?php if(isset($_GET['domain'])){ echo $_GET['domain']; } ?>">
                    <button type="submit" id="btnSearch" class="btn-search"><i class="fa fa-search"></i></button>
                </form>
            </div>
            <?php
                error_reporting(0);
                if(isset($_GET['domain'])){
                    $domain = $_GET['domain'];
                    if ( gethostbyname($domain) != $domain ) {
                        echo "<h3 class='fail'>Domain Already Registered!</h3>";
                    }
                    else {
                        echo "<h3 class='success'>Hurry, your domain is available!, you can register it.</h3>";
                    }
                }
            ?>
        </div>

        <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.7.2/css/all.css"/>
        <style type="text/css">
            body, h2, h3 {
                font-weight: normal;
                font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
                color: #333;
            }
            body {
                display: flex;
                flex-direction: column;
                justify-content: center;
                align-items: center;
                height: 90vh;
            }
            h2 {
                font-size: 26px;
                text-align: center;
            }
            h3 {font-size: 24px; }
            h3.success {
                color: #008000;
                text-align: center;
            }
            h3.fail {
                color: #ff0000;
                text-align: center;
            }
            .container {
                display: flex;
                flex-direction: row;
                justify-content: center;
                align-items: center;
            }
            .searchbar {
                padding: 6px 10px;
                width: 400px;
                max-width: 100%;
                border: none;
                margin-top: 1px;
                margin-right: 8px;
                font-size: 1em;
                border-bottom: #333 solid 2px;
                transition: 0.3s;
            }
            .searchbar::placeholder {
                font-size: 1em;
            }
            .searchbar:focus {
                outline: none;
            }
            .btn-search {
                cursor: pointer;
                text-decoration: none !important;
                font-size: 1.5em;
                padding-top: 5px;
                padding-bottom: 5px;
                background-color: transparent;
                border: none;
                outline: none;
            }
        </style>
    </body>
</html>

We hope you have found this article helpful. Let us know your questions or feedback if any through the comment section in below. You can subscribe our newsletter and get notified when we publish new WordPress articles for free. Moreover, you can explore here other related articles.

If you like our article, please consider buying a coffee for us.
Thanks for your support!

Support us on Buy me a coffee! Buy me a coffee!



17 Responses Leave a Comment

  1. Hi Speedy Sense.
    How can I use your code to make a page? For example, I make a Page on my website which URL is https://myexample.com/domain. I want it to display exactly what your code is display in demo mode. How can I do it? Because when I paste your code to HTML mode of WP, it can not understand PHP code in value attribute of input tag of form.
    Thank you and hope to receive your response soon.

    1. blank
      SpeedySense Editorial August 13, 2019 at 1:41 PM

      You probably need to check htaccess to archive this.

    2. Ok. Thank you. Your code is so great.

  2. Ok. Thank you. Your code is so great.

  3. Hey there was wondering if the code actually works cus I would need it on a blog page. Any ideas on how to turn it to a html page thanks

    1. blank
      SpeedySense Editorial October 22, 2019 at 5:26 PM

      This is very easy trick. thanks!

  4. This script is workaround solution. However, for the correct result send query to whois server to get actual status.

  5. very good code works well, but facing one issue, if the search field is empty how to display echo response?

  6. HI,

    thanks for the free code.
    Now i implemented it on a existing page, the problem is it redirects afther submit button, is there a way to not redirect it?

  7. it’s great thanks for this script, it helped me a lot

  8. thanks dear..i use it.

  9. It’s very helpful code I found. keep it up bro! Thanks

  10. Excellent code and simple to replicate for domain searches! Thanks for sharing

  11. Thank you very much. i have been searching for hours for a free tool

  12. All that is good is simple, thanks my friend for the good code

  13. Awesome Code….

Join the Discussion.