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.

 

 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.

 

 

 

Post a Comment

Previous Post Next Post