Usamos cookies para medir audiência e melhorar sua experiência. Você pode aceitar ou recusar a qualquer momento. Veja sobre o iMasters.
Boa tarde, bom vou direto ao ponto, tenho 3 arquivos aqui o altera_cliente.php e o formulario_editar_cliente.php e o ler_cliente.php bom e o seguinte o ler_cliente ele mostra oque tem no banco de dados faz uma listagem, funciona 100% o que esta dando errado e o altera_cliente.php tenho 2 campos que quero altera o nome_cliente e o cidade_cliente quando eu mando gravar a alteração nao retorna nenhum erro nem nada, e o campos continuam do mesmo jeito sem alterar, vou postar meus codigos: ler_cliente.php <!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>Documento sem título</title>
</head> <body>
<div align="center" > <h1>Administrar Clientes</h1>
</div>
<form id="form1" name="form1" method="post" action="ler_cliente.php"> <label for="filtrar">Pesquisa de cliente.:</label> <input name="filtrar" type="text" id="filtrar" size="50" /> <input type="submit" name="button" id="button" value="Pesquisar" />
</form>
<p><a href="formulario_insere_cliente.php">Cadastrar novo cliente</a></p>
<div align="center"></div>
<div align="center"> <table width="1011" border="1" cellspacing="5" cellpadding="5"> <tr> <td colspan="4"><div align="center">Clientes</div></td> </tr> <tr> </tr> <tr> <td width="331"><div align="center"><a href="ler_cliente.php?ordem=nome_cliente">Nome</div></td> <td width="73"><div align="center"><a href="ler_cliente.php?ordem=cidade_cliente">Cidade</div></td> <td colspan="2"><div align="center">Ações</div></td> </tr> <?php // faz conexao com o banco de dados require 'conexao.php'. // tabela se ordem for igual a zero vai iniciar com o bai_nome if (@$_REQUEST['ordem'] == '') $ordem = "nome_cliente". else $ordem = $_REQUEST['ordem']. // campo filtrar pesquisa if (@$_REQUEST['filtrar'] == '') $filtrar = "". else $filtrar = $_REQUEST['filtrar']. $sql_select = "select * from clientes where nome_cliente like'". $filtrar. "%' order by ". $ordem. $resultado = mysql_query($sql_select). // executa a variavel sql_select // função if para ver se deu erro ou nao if(!$resultado) echo tratar_erros(mysql_errno()). else { // achar o numero de registros $numero_registros = mysql_num_rows($resultado). // laço de repetição para mostrar informações while($registro = mysql_fetch_array($resultado)) {?> <tr> <td align="center"><b><?php echo strtoupper($registro['nome_cliente']).?></b></td> <td align="center"><b><?php echo strtoupper($registro['cidade_cliente']).?></b></td> <td width="42"><div align="center"><a href="formulario_editar_cliente.php?nome_cliente=<?php echo $registro['nome_cliente']?>&cidade_cliente=<?php echo $registro['cidade_cliente']?>">Alterar</a></div></td> <td width="41"><div align="center">Excluir</div></td> </tr> <?php } }?> <tr> <td colspan="4"><div align="center">Total de clientes encontrados.:<?php if ($numero_registros == '') echo " Nenhum cliente encontrado". else echo " ".$numero_registros.?> </div></td> </tr> </table>
</div>
<p> </p>
</body>
</html> formulario_editar_cliente.php <!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>Documento sem título</title>
</head> <body>
<form id="form1" name="form1" method="post" action=""> <div align="center"><b>Editar Cliente</b> </div>
</form>
<p> </p>
<form id="form2" name="form2" method="post" action="alterar_cliente.php"> <p> <label for="altera_nome">Alterar nome.:</label> <input name="altera_nome" type="text" id="altera_nome" size="40" value="<?php echo $_REQUEST['nome_cliente'].?>"/> </p> <p> <label for="altera_cidade">Alterar cidade.:</label> <input name="altera_cidade" type="text" id="altera_cidade" size="30" value="<?php echo $_REQUEST['cidade_cliente'].?>"/> </p> <p> <input type="submit" name="button" id="button" value="Alterar" /> </p>
</form>
<p> </p>
</body>
</html> altera_cliente.php: <?php require 'conexao.php'. $sql_altera = "update clientes set nome_cliente = '".$_POST['alterar_nome']."' where cidade_cliente = '". $_POST['alterar_cidade']."'". $resultado = mysql_query($sql_altera). if(!$resultado)
//echo mysql_errno().mysql_error(). echo tratar_erros(mysql_errno()). header("Location: ler_cliente.php"). exit. }
//echo "Gravado com sucesso".?>Carregando comentários...