how to put a domain checker in php?

Asked

Viewed 308 times

-1

Well, I am with a well developed website, however, I want to put a page to check whether the domain is already registered yes or no, I searched a lot before I got here, so none worked, my html code is like this

                        <div class="" id="chND_Verificar">
                             <label class=" control-label label_defaults" for="chND_Login" id="chND_Verificar">                   
                             </label>
                             <div class="">
                               <input type="text" placeholder="Digite o seu domínio" autocomplete="off" autofocus class="autofocus-caret-beginning" required ng-model="input.domain" name="domain" id="cart_domain_search_domain" ng-disabled="loading">
                             </div>
                          </div>                                                                                   
                             <div id="f1_upload_process" class="form-group" style="display:none;">
                                <label class=" control-label label_defaults"></label>
                                <img src="http://www.fdsacesse.com/code/media/images/loader.svg" width="32" />
                             </div>
                             <div class="form-group">
                                <label class=" control-label label_defaults"></label>
                                <input class="submit" type="submit" value="CONSULTAR" ng-disabled="searchForm.domain.$error.pattern || loading">
                             </div>

but I would like to know, how can I continue?

1 answer

2


You can use checkdnsrr or gethostbyname:

Documentation:

http://www.php.net/checkdnsrr

http://www.php.net/gethostbyname

Example of checkdnsrr:

<?php
 if ( checkdnsrr('example.com.', 'ANY') ) {
  echo "DNS Record found";
 }
 else {
  echo "NO DNS Record found";
 }
?>

Example of gethostbyname:

<?php
 $domain = 'example.com';
 if ( gethostbyname($domain) != $domain ) {
  echo "DNS Record found";
 }
 else {
  echo "NO DNS Record found";
 }
?>

source: https://stackoverflow.com/a/8693519/7437072

Or as William Nascimento quoted it in that reply .

Maybe what you need is a WHOIS query.

There is a library called https://github.com/regru/php-whois using a range of services for consultation https://github.com/regru/php-whois/blob/master/src/Phois/Whois/whois.servers.json

Example of use:

<?php
require_once 'vendor/autoload.php';

$sld = 'dominio.com.br';//Dominio que quer verificar

$domain = new Phois\Whois\Whois($sld);

if ($domain->isAvailable()) {
    echo 'Domínio disponível';
} else {
    echo 'Domínio indisponível';
}
  • In this case WHOIS allows me to check whether the domain that the customer wants for his site is available yes or no equal to this form link ?

  • Yes, only use the library as shown in the example

Browser other questions tagged

You are not signed in. Login or sign up in order to post.