0

I check if a domain exists with this code in my controller:

public function check_domain($domain)
    {
        if ( checkdnsrr($domain, 'A') ) {
          echo 0;//not available
         }
         else {
          echo 1;
         }
    }

I call this function using ajax, like this:

$.ajax({
                url: "main/check_domain/"+$('#domain').val()+"."+$('#tld').val(),
                type: "POST",               
                success: function (data) {
                    //alert(data);
                    if(data){
                    $('#verif').hide();
                    $('#reg').show();
                    }
                },
                error:function(data){
                  //alert(JSON.stringify(data));
                  alert('error');
                }
        });

I my network window I also see a 404 error for testwhois.php file . What am I doing wrong? whois.php file

Andreea Onica
  • 315
  • 5
  • 13
  • It doesn't seem like the code that you're showing has anything to do with it. The 404 indicates that `http://localhost/1/whois/testwhois.php` is not the correct path to execute your code. – Patrick Q Jul 18 '18 at 15:03
  • Are you using a specific framework? If so, can you provide your (config) route for `main/check_domain`. – steadweb Jul 18 '18 at 15:23
  • I'm using codeigniter, main/check_domain has status 200 (OK), but testwhois.php has status 404 (this must be related to the checkdnsrr function) – Andreea Onica Jul 18 '18 at 16:09
  • Not related to your question but note that checking for `A` record on a domain to see if it exists is flawed for multiple reasons. Some domains can be registered but not published in the DNS, by owner's will, registrar decision (like non payment) or registry decision (dispute). Even if it is published, the apex may not necessarily have an `A` record, especially if there is no website. – Patrick Mevzek Jul 20 '18 at 01:56

0 Answers0