-1
I have the following mistakes My head is frying too much and I can’t see the error
Notice: Undefined index: cxnome
Notice: Undefined index: search
Follows codes
<?php
try {
$con = new PDO('mysql:host=localhost;dbname=XXX', 'root', 'XXX');
} catch (PDOException $e) {
print $e->getMessage();
}
?>
<form name="form1" method="post" action="">
<label>
<input name="cxnome" type="text" id="cxnome" value="" size="30">
</label>
<label></label>
<label>
<input type="submit" name="pesquisar" value="Pesquisar">
</label>
<label>
<input type="reset" name="Submit2" value="Limpar">
</label>
</form>
<?php
$nome=$_POST['cxnome'];
$pesquisa=$_POST['pesquisar'];
if(isset($pesquisa)&&!empty($nome))
{
$stmt = $con->prepare("SELECT * FROM usuarios WHERE nome LIKE :letra");
$stmt->bindValue(':letra', '%'.$nome.'%', PDO::PARAM_STR);
$stmt->execute();
$resultados = $stmt->rowCount();
if($resultados>=1){
echo "Resultado(s) encontrado(s): ".$resultados."<br /><br />";
while($reg = $stmt->fetch(PDO::FETCH_OBJ))
{
echo $reg->nome." - ";
echo $reg->email."<br />";
}
}
else
{
echo "Não existe usuario cadastrado";
}
}
else{
echo "Preencha o campo de pesquisa";
}
?>
I’ve tried but it’s complicated - to facilitate you could explain better how you have tried, what tried, what did not work...
– Melissa
It’s just hard to get the search to stay on the same page because as soon as the search is done it is redirected to another page
– Lucas Giovanni