Take user information and check if domain is available

Asked

Viewed 19 times

1

I want to make a code where it checks the user’s information and sees if the domain exists. However, it returns absolutely nothing.

HTML:

 <form action="teste.php" method="POST" class="form-inline">
      <label class="sr-only" for="inlineFormInputName2">WWW</label>
            <input type="text" class="p-3 form-control form-control-lg mb-2 mr-sm-2 input-ro" id="inlineFormInputName2" placeholder="www." readonly>

      <label class="sr-only" for="inlineFormInputGroupUsername2">Domínio</label>
      <div class="input-group justify-content-center mb-2 mr-sm-2">
            <input type="text" name="dominio" class="input-dom form-control form-control-lg" id="inlineFormInputGroupUsername2" placeholder="Digite o domínio desejado">
      </div>

      <div class="form-check mb-2 mr-sm-2 select-padding">
           <select name="com" class="form-control form-control-lg">
                   <option>.com</option>
                   <option>.com.br</option>
                   <option>.net</option>
           </select>
       </div>
       <button type="submit" class="btn btn-dominio btn-outline-danger">
               <i class="fas fa-search"></i>
       </button>
  </form>

PHP:

 <?
require "registro-de-dominios.php";

$dominio = $_POST['dominio'];
function dominio_disponivel($dominio){
 if(checkdnsrr($dominio, 'ANY') && gethostbyname($dominio) != $dominio)
        echo "<p>Domínio <b>disponível.</b></p>";
    else
        echo "<p>Domínio <b>indisponível.</b></p>";
}
?>
  • From what it seems, in your html there is no name attribute to its inputs, the POST method recovers the value according to the inputs' Names.

  • I put the attribute name="domain" in the second input, I also put it in select, but in php I just called the domain.

  • Then probably the problem should be in this file registro-de-dominios.php

  • I don’t know. The funny thing is that if I put if(dominio_disponivel('zerobugs.com.br'))&#xA; echo "<p>Domínio zerobugs.com.br <b>disponível.</b></p>";&#xA;else&#xA; echo "<p>Domínio zerobugs.com.br <b>indisponível.</b></p>";&#xA;if(dominio_disponivel('zerobugs-asd.com.br'))&#xA; echo "<p>Domínio zerobugs-asd.com.br <b>disponível.</b></p>";&#xA;else&#xA; echo "<p>Domínio zerobugs-asd.com.br <b>indisponível.</b></p>"; outside the function, inside php, will return me both echos.

  • Where its function is called dominio_disponivel ?

  • According to your php, you do not call the function dominio_disponivel . You can call right after that line $dominio = $_POST['dominio']; the function dominio_disponivel($dominio)

  • I just tested this. You were right, it’s a bug in HTML, because it doesn’t assign the attribute name in the form.

  • I saw the attribute name="dominio" in the second input

  • I called the function, at the end of PHP I put dominio_disponivel($dominio), however, when I test it, only unavailable domains appear. Even putting a domain that is available, it goes to Else.

  • You are concatenating the domain value with the name select com? How is your function checkdnsrr ?

Show 5 more comments
No answers

Browser other questions tagged

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