Usamos cookies para medir audiência e melhorar sua experiência. Você pode aceitar ou recusar a qualquer momento. Veja sobre o iMasters.
Pessoal, nao estou conseguindo fazer essa busca funcionar... aparece o erro Notice: Undefined index: buscar3 in C:\xampp\htdocs\marcela\CoteJa\paginas\resultado_usuario.phpon line 26
primeiramente tenho a pagina inicial do administrador onde coloquei a funçao que faz a busca
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Administrador</title>
<link rel="stylesheet" href="../css/Style_adm.css"/>
<script>
function buscar3() var strBuscar3;
strBuscar = frmBuscar.txt_busca.value;
abrir('resultado_usuario.php?buscar='+strBuscar3,'conteudo')
}
</script>
</head>
<body>
<div id="tudo">
<?php
session_start();
?>
<div id="topo">
<div id="imagem"><img src="../images/Logo coteja.png" alt="CoteJá" width="108" height="99" align="left" /> </div>
<div id="topo2">
<center><font size="5" > Bem Vindo! <?php echo $_SESSION["nome_usuario"];?></font></center>
</div> <!--topo2-->
</div> <!--topo-->
<div id="colunaesquerda">
<table width="90%" border="0" >
<tr><td>Cadastros</td></tr>
<tr>
<?php
if($_SESSION["tipo_login"]=="admin")
{
echo " <td><a href='cadastro_usuario.php' target='conteudo' >Cadastro Usuário</a></td>";
}
else
{
echo " <td></td>";
}
?>
</tr>
<tr>
<td><a href="cadastro_produto.php" target="conteudo">Cadastro Produto</a></td>
</tr>
<tr>
<td><a href="cadastro_valor.php" target="conteudo">Cadastro Valor Produto</a></td>
</tr>
<tr>
<?php
if($_SESSION["tipo_login"]=="admin")
{
echo " <td><a href='cadastro_receita.php' target='conteudo' >Cadastro Receita</a></td>";
}
else
{
echo " ";
}
?>
</tr>
<tr>
<td height="20"><a href="cadastro_supermercado.php" target="conteudo">Cadastro Supermercado</a></td>
</tr>
<tr><td> </td></tr>
<tr><td>Consulta/Alteração/Exclusão</td></tr>
<tr>
<td><a href="consulta_usuario.php" target="conteudo"> Consulta usuários</a></td>
</tr>
<tr>
<td><a href="consulta_valor.php" target="conteudo">Consulta valores</a></td>
</tr>
<tr>
<td><a href="consulta_produto.php" target="conteudo">Consulta produtos</a></td>
</tr>
<tr>
<td><a href="consulta_supermercado.php" target="conteudo">Consulta supermercado</a></td>
</tr>
<tr><td> </td></tr>
<tr>
<td><a href="sair.php">Sair</a></td>
</tr>
</table>
</div>
<div id="colunadireita">
<iframe name="conteudo"
align="center"
width="680"
height="450"
scrolling="auto"
frameborder="0"
src="">
</iframe>
</div>
<div id="rodape">
<center><b>CoteJá - O seu site de cotação</b></center>
</div>
</div>
</body>
</html>
depois tenho a pagina de consulta de usuarios onde esta o botao de busca, pois qdo tiver muitos usuarios, eu posso procura-lo pela busca
<center><b>USUÁRIOS</b><br />
<form name="frmBuscar" action="resultado_usuario.php" >
<input class="txt_busca" type="text" name="txt_busca" id="txt_busca" maxlength="20" size"20" placeholder="Digite aqui sua busca"/>
<input class="btn_buscar" type="submit" name="btn_buscar" id="btn_buscar" value="Buscar" onclick="buscar3();" />
</form></center>
<?php
include "conexao.php";
$c1=new conexao ("localhost","root","","bdcoteja");
//3 - criando sql para consulta
$sql="select * from tbusuario";
//4- efetuando a consulta
$c1->realizarConsulta($sql);
$pasta_destino="imagens/";
//5- pegar os dados vindos da tabela
// mysql_fetch_array() - obtem uma linha de resultado, armazenando em um array
echo "<center><table width='200' border='0' cellpadding='7'>
<tr>
<td>Nome </td>
<td>Login</td>
<td>Senha</td>
<td>Tipo</td>
<td>Excluir</td>
<td>Editar</td>
</tr>";
while ($linha=mysql_fetch_array($c1->getConsulta()))
{
$id=$linha["idlogin"];
$n=$linha["nome"];
$l=$linha["login"];
$s=$linha["senha"];
$t=$linha["tipo"];
echo "
<tr>
<td>".$n."</td>
<td>".$l."</td>
<td>".$s."</td>
<td>".$t."</td>
<td align='center'><a href=exclui_usuario.php?cod=$id><img src='../images/excluir.jpg' /></a></td>
<td align='center'><a href=altera_usuario.php?cod=$id><img src='../images/editar2.png' /></a></td>
</tr>";
//echo "Id do usuario ".$id."<br>";
//echo "Nome do usuario ".$n."<br>";
//echo "Login do usuario ".$l."<br><br>";
}
echo "</table></center>";
// 5- fechando a conexao
$c1->fecharConexao();
?>
apos isso, tenho a pagina resultado_usuarios.php
<?php
include "conexao_mysql.php";
//$busca = isset($_POST["buscar3"]) ? $_POST["buscar3"] : '';
$busca=$_GET["buscar3"];
if (isset($_POST["btn_buscar"]));
{
$resultado=mysql_query("SELECT * FROM tbusuario where nome LIKE ('%".$busca."%') ");
echo "<center><b>Resultado da busca para: </b>".$busca. "</center>";
echo "<center><table width='200' border='0' cellpadding='7'>
<tr>
<td>Nome </td>
<td>Login</td>
<td>Senha</td>
<td>Tipo</td>
<td>Excluir</td>
<td>Editar</td>
</tr>";
while ($linha=mysql_fetch_array($resultado))
{
$id=$linha["idlogin"];
$n=$linha["nome"];
$l=$linha["login"];
$s=$linha["senha"];
$t=$linha["tipo"];
echo "
<tr>
<td>".$n."</td>
<td>".$l."</td>
<td>".$s."</td>
<td>".$t."</td>
<td align='center'><a href=exclui_usuario.php?cod=$id><img src='../images/excluir.jpg' /></a></td>
<td align='center'><a href=altera_usuario.php?cod=$id><img src='../images/editar2.png' /></a></td>
</tr>";
}
echo "</table>";
}
?>
</div>
ACHO QUE O PROBLEMA ESTA SENDO O LOCAL QUE COLOQUEI O SCRIPT... DEVE SER ALGO SIMPLES POREM DEVIDO A MINHA POUCA EXPERIENCIA, ESTOU TENDO DIFICULDADES
Carregando comentários...