0
I’m having some difficulty displaying a message when the query does not return results. When the select
returns 1 result "if(mysqli_num_rows($result1) > 0)"
is showing correctly, but when it does not return, it brings nothing (else
).
Follow my code below:
<div class="part3">
<center><h2>Redefina a sua nova senha</h2></center>
<?php
if(isset($_GET['hash'])) {
$hash = $_GET['hash'];
$sql1 = "SELECT * from hr_link where link = '$hash' limit 1";
$result1 = mysqli_query($connect, $sql1);
while($reg = mysqli_fetch_array($result1)){
$hash2 = $reg['link'];
$idusuario = $reg['idusuario'];
if(mysqli_num_rows($result1) > 0) {
?>
<center>
<form style="max-width: 450px" method="POST" name="formuser" action="cadastrok2.php" class="form-horizontal">
<input type="password" name="txtnovasenha" placeholder="Nova Senha" class="txtfieldd" />
<input type="password" name="txtrpt" placeholder="Confirme a nova senha" class="txtfieldd" />
<input type="hidden" name="txtidusuario" value="<?php echo $idusuario ?>" />
<br/>
<center>
<input type="submit" name="rec_key" value="Salvar" onclick="return validar() " style="color: white; background: green; padding: 15px; font-size: 18px; border-radius: 5px; margin-top: 20px; cursor: pointer;border: none"/>
</center>
</form>
</center>
<?php
} else { ?>
<center>
<br/>
<form style="max-width: 450px" name="loginform" method="post" action="userauth.php?">
<a href="?id=1" class="btn_modal3"><h5>Link expirou. Clique aqui para gerar novamente</h5></a>
<br/>
<center></center>
</form>
</center>
<?php
}
}
}else{
?>
<center>
<form style="max-width: 450px" name="loginform" method="post" action="userauth.php?">
<a href="?id=1" class="btn_modal3"><h5>Link expirou. Clique aqui para gerar novamente</h5></a>
<br/>
<center>
</center>
</form>
</center>
<?php } ?>
Thank you very much, Inkeliz. It worked, it helped me a lot.
– Everton Fraga