Jump to content
Fórum Script Brasil
  • 0

UPDATE PHP+MYSQL


Josué Costa

Question

alguém poderia dar uma dica de como resolver esse problema, por algum motivo que não consigo identificar esse codigo não consegue extrair as informações do BD para fazer atualização do cadastro.

abaixo codigo da pagina editar.php

<?php

$cod = base64_decode($_GET["id"]);

//seleciona todos da tabela usuarios onde cod recebe o valor da variavel $cod

$sql = "SELECT * FROM usuarios WHERE id = ".$cod;

include("fontes/conexao.php");

$conexao = mysql_connect("$local", "$usuario", "$senha") or die(mysql_error());

$db = mysql_select_db("$selecione",$conexao) or die (mysql_error());

//Executando o comando sql no MYSQL

$rs = mysql_query($sql,$conexao);

$row = mysql_fetch_array($rs);

?>

<h3>Formulário de Edição de dados</h3>

<form action=editar2.php" method="post">

Nome:<br/>

<input type="text" name="nome" value="<?php echo $row["nome]?>"/><br/>

E-mail:<br/>

<input type="text" name="email" value="<?php echo $row["email"]?>"/><br/>

Telefone:<br/>

<input type=text" name="telefone" value="<?php echo $row["telefone]?>"/><br/>

Cpf:<br/>

<input type="text" name="cpf" value="<?php echo $row["cpf"]?>"/><br/>

<input type=hidden" name="id" value="<?php echo $row["id]?>" />

<input type="submit" value="Alterar Cadastro" />

</form>

<br/>

<a href="consultar.php">Consultar</a>

Link to comment
Share on other sites

1 answer to this question

Recommended Posts

  • 0

cara..d boa.. tenta dar 1 organizada.. assim:

1- conexão

2- declara variavel índice (id)

3- consulta ao banco (mysql_query)

4- loop (while) - entre parênteses - p/ exibir os dados

5- conteudo do "while": entre chaves

e olha.. da 1 melhorada no html...

tipo assim:

(o form ta ok..)

<?php
$conexao = mysql_connect("$local", "$usuario", "$senha") or die(mysql_error());
$db = mysql_select_db("$selecione",$conexao) or die (mysql_error());

$cod = base64_decode($_GET["id"]);
$rs = mysql_query("SELECT * FROM usuarios WHERE id = '$cod' ");
while($row = mysql_fetch_array($rs))
{
?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Pesquisar</title>
</head>
<body>
<h3>Formulário de Edição de dados</h3>
<form action="editar2.php" method="post">
Nome:<br/>
<input type="text" name="nome" value="<?php echo $row['nome']?>"/><br/>
E-mail:<br/>
<input type="text" name="email" value="<?php echo $row['email']?>"/><br/>
Telefone:<br/>
<input type="text" name="telefone" value="<?php echo $row["telefone"]?>"/><br/>
Cpf:<br/>
<input type="text" name="cpf" value="<?php echo $row["cpf"]?>"/><br/>
<input type="hidden" name="id" value="<?php echo $row["id"]?>" />
<input type="submit" value="Alterar Cadastro" />
</form>
</body>
<?php
}
?>
</html>

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



  • Forum Statistics

    • Total Topics
      152.2k
    • Total Posts
      652k
×
×
  • Create New...