Usamos cookies para medir audiência e melhorar sua experiência. Você pode aceitar ou recusar a qualquer momento. Veja sobre o iMasters.
Ola boa noite, tipo, estou vendo um curso de PHP q baxei, e esta tudo dando certo, so q na opçao de editar os dados q ja gravei na tabela , n edita me retorna p\ a pagina "HOME"
vou posta o cogido p\ melhor esplicar.
Pagina Conteudo
<!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](http://www.w3.org/1999/xhtml)">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Index</title>
</head>
<body>
<?php
switch ($_GET['pagina']){
case 'cadastro_carros';
include "cadastro_carros.php";
break;
case 'teladecontrole';
include "teladecontrole.php";
break;
case 'contato';
include "contato.php";
break;
case 'clientes_cadastrados';
include "clientes_cadastrados.php";
break;
case 'cadastro_clientes';
include "cadastro_clientes.php";
break;
default;
include ("home.php");
}
?>
</div><!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](http://www.w3.org/1999/xhtml)">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Cadastro de Clientes</title>
</head>
<?php
include "css.php";
?>
<body>
<div id="geral_conteudo">
<?php
include "menu.php";
?>
<div id="box_right">
<h2>Cadastro de Clientes</h2>
<hr />
<div id="form_u">
<div id="form_input_u">
<?
if($_GET['funcao'] != "editar"){
?>
<form name="signup" method="post" action="funcoes.php?funcao=gravar">
Nome:<input type="text" name="nome" id="nome" />
CPF:<input type="text" name="cpf" id="cpf" />
RG:<input type="text" name="rg" id="rg" />
<br />
<br />
<br />
Telefone:<input type="text" name="telefone" id="telefone" />
E-Mail<input type="text" name="email" id="email" />
Cidade:<input type="text" name="cidade" id="cidade" />
<br />
<br />
<br />
CEP:<input type="text" name="cep" id="cep"/>
Endereço<input type="text" name="endereco" id="edereco" />
Estado:<input type="text" name="estado" id="estado" />
<br />
<br />
<input type="submit" value="Cadastrar" />
</form>
<?
}
?>
<?
include "conexao.php";
if($_GET['funcao'] == "editar"){
$id = $_GET['id'];
$sql_update = mysql_query("SELECT * FROM usuarios WHERE id = '$id' ");$nome = $linha['nome'];
$cpf = $linha['cpf'];
$rg = $linha['rg'];
$telefone = $linha['telefone'];
$email = $linha['email'];
$cidade = $linha['cidade'];
$cep = $linha['cep'];
$endereco = $linha['endereco'];
}
?>
<form name="signup" method="post" action="funcoes.php?funcao=editar$id=<? echo" $id" ?>">
Nome:<input type="text" name="nome" id="nome" value="<? echo "$nome" ?>" />
CPF:<input type="text" name="cpf" id="cpf" value="<? echo "$cpf" ?> "/>
RG:<input type="text" name="rg" id="rg" <? echo "$rg" ?> />
<br />
<br />
<br />
Telefone:<input type="text" name="telefone" id="telefone" value=" <? echo "$telefone" ?>" />
E-Mail<input type="text" name="email" id="email" value" <? echo "$email" ?> "/>
Cidade:<input type="text" name="cidade" id="cidade" value"<? echo "$cidade" ?>" />
<br />
<br />
<br />
CEP:<input type="text" name="cep" id="cep" value" <? echo "$cep" ?> "/>
Endereço<input type="text" name="endereco" id="edereco" value"<? echo "$endereco" ?>" />
Estado:<input type="text" name="estado" id="estado" value" <? echo "$estado" ?>"/>
<br />
<br />
<input type="submit" value="Alterar" />
</form>
<?
}
?>
</div>
</div>
</div>
</div>
</body>
</html>
Pagina Clientes cadastrados
<!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](http://www.w3.org/1999/xhtml)">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Clientes Cadastrados</title>
</head>
<?php
include "css.php";
?>
<body>
<div id="geral_conteudo">
<?php
include "menu.php";
?>
<div id="box_right">
<h2>Clientes Cadastrados</h2>
<hr />
<div id="tabela">
<table width="700" border="1">
<tr>
<td width="603" align="center" bgcolor="#999999">Nome</td>
<td width="70" align="center" bgcolor="#999999">Editar</td>
<td width="70" align="center" bgcolor="#999999">Remover</td>
</tr>
<?
include "conexao.php";
$sql_visualizar = mysql_query(" SELECT * FROM usuarios ORDER BY nome");
while($linha = mysql_fetch_array($sql_visualizar)){
$pega_nome = $linha['nome'];
$id = $linha['id'];
?>
<tr>
<td bgcolor="#999999" ><? echo $pega_nome ?></td>
<td width=" 70" align="center" bgcolor="#999999" > <a href="?pagina=cadastro_clientes.php?funcao=editar&id=<? echo $id ?>"> Editar </a> </td>
<td width=" 70" align="center" bgcolor="#999999" > <a href="funcoes.php?funcao=excuir&id=<? echo $id ?>"> Excluir </a> </td>
</tr>
<?
}
?>
</table>
</div>
</div>
</div>
</body>
</html>
Pagina de Menu
<!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](http://www.w3.org/1999/xhtml)">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<div id="box_left">
<h2></h2>
<ul>
<li><a href="?pagina=home">Home</a></li>
<li><a href="?pagina=teladecontrole">Tela De Controle</a></li>
<li><a href="?pagina=cadastro_clientes">Cadastro de Clientes</a></li>
<li><a href="?pagina=cadastro_carros">Cadastro de Carrros</a></li>
<li><a href="?pagina=clientes_cadastrados">Clientes Cadastrados</a></li>
<li><a href="?pagina=contato">Contato</a></li>
</ul>
</div>
</body>
</html>Carregando comentários...