Usamos cookies para medir audiência e melhorar sua experiência. Você pode aceitar ou recusar a qualquer momento. Veja sobre o iMasters.
galera como pegar o id do form para atualizar veja os codigos no meu soh retorna nada.
editar.php
<?php
include('conexao.php');
$id=$_GET['id'];
$sql="SELECT *FROM cadastroprof WHERE id='$id'";
$query=mysql_query($sql);
$linha=mysql_fetch_array($query);
$id=$linha['id'];
$nome=$linha['nome'];
$endereco=$linha['endereco'];
$cidade=$linha['cidade'];
$uf=$linha['uf'];
$cep=$linha['cep'];
$telefone=$linha['telefone'];
$cpf=$linha['cpf'];
$rg=$linha['rg'];
$dn=$linha['dn'];
$curso=$linha['curso'];
?>
<h1 align=center>Cadastro de Professor</h1>
<form method="POST" action="editar_id.php">
<table align=center border="0" width="300">
<tr>
<td width=100>Nome</td>
<td width=200><input type=text name=nome value="<?php echo $nome; ?>"></td>
</tr>
<tr>
<td width=100>Endereço</td>
<td width=200><input type=text name=endereco value="<?php echo $endereco; ?>"></td>
</tr>
<tr>
<td width=100>Cidade</td>
<td width=200><input type=text name=cidade value="<?php echo $cidade; ?>"></td>
</tr>
<tr>
<td width=100>UF</td>
<td width=200><input type=text name=uf value="<?php echo $uf; ?>" size=4 maxlength=2></td>
</tr>
<tr>
<td width=100>CEP</td>
<td width=200><input type=text name= cep value="<?php echo $cep; ?>"></td>
</tr>
<tr>
<td width=100>Telefone</td>
<td width=200><input type=text name=telefone value="<?php echo $telefone; ?>"></td>
</tr>
<tr>
<td width=100>CPF</td>
<td width=200><input type=text name=cpf value="<?php echo $cpf; ?>"></td>
</tr>
<tr>
<td width=100>RG</td>
<td width=200><input type=text name=rg value="<?php echo $rg; ?>"></td>
</tr>
<tr>
<td width=100>Data de Nascimento</td>
<td width=200><input type=text name=dn value="<?php echo $dn; ?>"></td>
</tr>
<tr>
<td width=100>Curso que Leciona</td>
<td width=200><input type=text name=curso value="<?php echo $curso; ?>"></td>
</tr>
<input type=hidden name=id value="<?php $id; ?>">
<tr>
<td width=100><input type=submit value=Editar></td>
<td width=200><input type=reset value=Padrão></td>
</tr>
</table>
</form>
editar_id.php
<?php
include('conexao.php');
$id=$_POST['id'];
$nome=$_POST['nome'];
$endereco=$_POST['endereco'];
$cidade=$_POST['cidade'];
$uf=$_POST['uf'];
$cep=$_POST['cep'];
$telefone=$_POST['telefone'];
$cpf=$_POST['cpf'];
$rg=$_POST['rg'];
$dn=$_POST['dn'];
$curso=$_POST['curso'];
$sql="UPDATE cadastroprof SET nome=$nome,endereco=$endereco,cidade=$cidade,uf=$uf,cep=$cep,telefone=$telefone,cpf=$cpf,rg=$rg,
dn=$dn,curso=$curso WHERE id=$id ";
$query=mysql_query($sql);
if($query){
echo 'ok';
}else{
echo 'erro';
}
?>Carregando comentários...