Domain Name Checker Tool using PHP

0
578

A domain name availability checker is a tool used to determine whether a desired domain name is available for registration. In today’s digital age, having an online presence is crucial for businesses and individuals alike. A domain name is the address of a website, and it plays a crucial role in establishing your brand online.

Before registering a domain name, it’s important to check its availability to ensure that it hasn’t already been taken. A domain name availability checker makes this process simple and easy. You simply enter the desired domain name, and the tool will check if it’s available for registration. If the domain name is taken, the checker will often provide suggestions for similar, available names.

Using a domain name availability checker has several benefits. First and foremost, it saves time and effort. By checking the availability of a domain name before registering it, you can avoid the frustration of finding out that the name you wanted has already been taken. Additionally, it helps you avoid the risk of infringing on someone else’s trademark.

Another benefit of using a domain name availability checker is that it allows you to reserve your desired domain name as soon as it becomes available. Many checkers offer a “backorder” service, which means that they will automatically register the domain name on your behalf as soon as it becomes available. This is particularly useful for businesses and individuals who want to secure a specific domain name for their brand.

In conclusion, a domain name availability checker is an essential tool for anyone who wants to establish an online presence. Whether you’re a business looking to establish your brand or an individual seeking a personal website, a domain name availability checker can help you secure the domain name you want. With its many benefits, including saving time, avoiding trademark infringement, and reserving your desired domain name, it’s a must-have tool for anyone looking to build a website.

ALSO READ  Install Laravel on Ubuntu with 4 simple steps

Follow this video for complete guidance :

Domain Name Checker Tool using PHP

We need to create two files for this :

1. index.php

2. search.php

1. index.php

<!DOCTYPE html>
<html>
  <head>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <style>
      body{
        width:100%;
        position: relative;
        height:100vh;
        overflow: hidden;
      }
      .page-inner{
        text-align: center;
        position: absolute;
        top:40%;
        left: 50%;
        transform: translate(-50%,-50%);
      }
      .searchbar{
        width: 400px;
        max-width: 100%;
        border: none;
        margin-top: 1px;
        margin-right: 8px;
        font-size: 1em;
        border-bottom: #333 solid 2px;
        transition: 0.3s;
        padding: 12px 5px;
        background-color: transparent;
      }
      .searchbar:focus {
        outline: none;
      }
      .response{
        margin-top:20px;
      }
      .response span{
        padding:10px;
        color:#fff;
      }
      .success{
        background-color: #63a463;
      }
      .danger{
        background-color: #d77373;
      }
    </style>
    <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.3/jquery.min.js"></script>
    </head>
  <body>
    <div class="page-inner">
      <h2>Check Domain Name Availability</h2>
      <input class="searchbar" type="text" name="domain" placeholder="google.com">
      <div class="response">Enter the domain and press enter to check</div>
    </div>

    <script type="text/javascript">

    $('.searchbar').on('keypress',function(e) {
        if(e.which == 13) {
            search();
        }
    });

      function search(){
        $(".response").html('Checking ...');
        domain = $('.searchbar').val();
        $.ajax({
          url:'search.php?domain='+domain,
          type:'get',
          success:function(res){
            $(".response").html(res);
          }
        });
      }
    </script>
  </body>
</html> 

 

2. search.php

<?php

$domain = (isset($_GET['domain']))?$_GET['domain']:false;
if (strpos($domain, ".com") !== false) {

}else{
    $domain .= '.com';
}

if($domain){
    $output = shell_exec("whois $domain");
    if (strpos($output, "No match for") !== false) {
        echo '<span class="success">'.$domain.' is available for purchase</span>';
    } else {
        echo '<span class="danger">'.$domain.' is not available for purchase</span>';
    }
}

 

 

 

Comments are closed.