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.
– Pedro Henrique
I put the attribute name="domain" in the second input, I also put it in select, but in php I just called the domain.
– Felipe Moreira
Then probably the problem should be in this file
registro-de-dominios.php
– Pedro Henrique
I don’t know. The funny thing is that if I put
if(dominio_disponivel('zerobugs.com.br'))
 echo "<p>Domínio zerobugs.com.br <b>disponível.</b></p>";
else
 echo "<p>Domínio zerobugs.com.br <b>indisponível.</b></p>";
if(dominio_disponivel('zerobugs-asd.com.br'))
 echo "<p>Domínio zerobugs-asd.com.br <b>disponível.</b></p>";
else
 echo "<p>Domínio zerobugs-asd.com.br <b>indisponível.</b></p>";
outside the function, inside php, will return me bothechos
.– Felipe Moreira
Where its function is called
dominio_disponivel
?– Pedro Henrique
According to your php, you do not call the function
dominio_disponivel
. You can call right after that line$dominio = $_POST['dominio'];
the functiondominio_disponivel($dominio)
– adventistaam
I just tested this. You were right, it’s a bug in HTML, because it doesn’t assign the attribute
name
in theform
.– Felipe Moreira
I saw the attribute
name="dominio"
in the second input– adventistaam
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.– Felipe Moreira
You are concatenating the domain value with the name select
com
? How is your functioncheckdnsrr
?– adventistaam