Sandro Caiado 0 Denunciar post Postado Julho 4, 2008 Caro Fabyo, eu tenho um exemplo aqui sobre o que você falou, mas nunca funcionou. Quando eu clico no enviar para inserir um registro a pagina fica em branco e ele nao insere. É um bom exemplo onde você tem o insert, update e delete num so arquivo, veja se ficaria bacana incorporar no seu exemplo. Se voce conseguir identificar o erro do porquê não funcionar, eu te agradeço. ================== Segue o arquivo de nome set.php //função incluir clientes if ($acao=='incluir') { $ac=mysql_query("insert into clientes( c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18, c19, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30) values ('$c1','$c2','$c3','$c4','$c5','$c6','$c7','$c8','$c9','$c10', '$c11','$c12','$c13','$c14','$c15','$c16','$c17','$c18','$c19','$c20', '$c21','$c22','$c23','$c24','$c25','$c26','$c27','$c28','$c29','$c30')") or die (mysql_error()); echo"<script language=javascript>alert('Operação efetuada com sucesso!')</script>"; echo"<script language=javascript>location.href='incluir.php'</script>"; mysql_close(); // fim da função incluir } //função alterar clientes if ($acao=='up') { $ac=mysql_query ("update clientes set c1= '$c1 ', c3= '$c3 ', c4= '$c4 ', c5= '$c5 ', c6= '$c6 ', c7= '$c7 ', c8= '$c8 ', c9= '$c9 ', c10='$c10', c11='$c11', c12='$c12', c13='$c13', c14='$c14', c15='$c15', c16='$c16', c17='$c17', c18='$c18', c19='$c19', c20='$c20', c21='$c21', c22='$c22', c23='$c23', c24='$c24', c25='$c25', c26='$c26', c27='$c27', c28='$c28', c29='$c29', c30='$c30' where cliente='$cliente'") or die (mysql_error()); echo"<script language=javascript>alert('Operação efetuada com sucesso!')</script>"; echo"<script language=javascript>location.href='listar.php'</script>"; mysql_close(); } //fim da função alterar //função remover if ($acao=='del') { $ac=mysql_query("delete from clientes where cliente='$cliente'") or die (mysql_error()); echo"<script language=javascript>alert('Operação efetuada com sucesso!')</script>"; echo"<script language=javascript>location.href='listar.php'</script>"; mysql_close(); } //fim da função remover ?>======== Abs e obrigado! Compartilhar este post Link para o post Compartilhar em outros sites
Balero 0 Denunciar post Postado Julho 5, 2008 Fabyo, primeiramente muito obrigado pelo Sistema! ^^ Eu modifiquei ele, mas só que estou com problemas na hora de Editar um cadastro. Você pode verificar por aqui: http://micaelborin.com/sistema/editar.php?id=4 , aparece a mensagem: <br /> <b>Notice</b>: Undefined variable: nome in <b>/home/micael/public_html/sistema/editar.php</b> on line <b>39</b><br /> dentro dos Campos. Você poderia me ajudar? Segue abaixo o meu: editar.php <?php if(file_exists("init.php")) { require "init.php"; } else { echo "Arquivo init.php nao foi encontrado"; exit; } if(!function_exists("Abre_Conexao")) { echo "Erro o arquivo init.php foi auterado, nao existe a função Abre_Conexao"; exit; } $id = $_GET["id"]; Abre_Conexao(); $re = mysql_query("select count(*) as total from cadastro where id_usuario = $id"); $total = mysql_result($re, 0, "total"); ?> <!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=iso-8859-1" /> <title>Cadastro</title> <style> <!-- .textBox { border:1px solid gray; width:200px;} --> </style> </head> <body> <form id="form1" name="form1" method="post" action="salvar_edicao.php"> <input type="hidden" name="id" value="<?php echo $id; ?>" /> <table width="400" border="0" align="center"> <tr> <td width="145">Nome</td> <td width="245"><input name="nome" type="text" id="nome" maxlength="45" class="textBox" value="<?php echo $nome["nome"]; ?>" /></td> </tr> <tr> <td>Versão</td> <td><input name="versao" type="text" id="versao" maxlength="64" class="textBox" value="<?php echo $dados["versao"]; ?>" /></td> </tr> <tr> <td>Configuravel</td> <td><input name="configuravel" type="radio" value="S" <?php echo $dados["configuravel"] == "S" ? "checked=\"checked\"" : ""; ?> /><label>Sim</label> <input name="configuravel" type="radio" value="N" <?php echo $dados["configuravel"] == "N" ? "checked=\"checked\"" : ""; ?> /> <label>Não</label></td> </tr> <tr> <td>Descrição</td> <td><input name="descricao" type="text" id="descricao" maxlength="30" class="textBox" value="<?php echo $dados["descricao"]; ?>" /></td> </tr> <tr> <td>Tradução - Pt-br</td> <td><input name="traducao_ptbr" type="text" id="traducao_ptbr" maxlength="30" class="textBox" value="<?php echo $dados["traducao_ptbr"]; ?>"/></td> </tr> <tr> <td>Dificuldade</td> <td><input name="dificuldade" type="text" id="dificuldade" maxlength="20" class="textBox" value="<?php echo $dados["dificuldade"]; ?>"/></td> </tr> <tr> <td>Tempo</td> <td><input name="tempo" type="text" id="tempo" maxlength="45" class="textBox" value="<?php echo $dados["tempo"]; ?>"/></td> </tr> <tr> <td>Discussão em Português</td> <td><input name="disc_pt" type="text" id="disc_pt" maxlength="40" class="textBox" value="<?php echo $dados["disc_pt"]; ?>"/></td> </tr> <tr> <td>Discussão em Inglês</td> <td><input name="disc_en" type="text" id="disc_en" maxlength="10" class="textBox" value="<?php echo $dados["disc_en"]; ?>"/></td> </tr> <tr> <td>Download</td> <td><input name="download" type="text" id="download" maxlength="10" class="textBox" value="<?php echo $dados["download"]; ?>"/></td> </tr> <tr> <td> </td> <td><input type="submit" name="Submit" value="Salvar" style="cursor:pointer;" /></td> </tr> </table> </form> </body> </html> Obrigado, Micael Compartilhar este post Link para o post Compartilhar em outros sites
Fabyo 66 Denunciar post Postado Julho 5, 2008 <?php echo $nome["nome"]; ?> o correto é <?php echo $dados["nome"]; ?> Compartilhar este post Link para o post Compartilhar em outros sites
Balero 0 Denunciar post Postado Julho 5, 2008 Fabyo, muito obrigado pela atenção. Modifiquei o Arquivo, mas mesmo assim na hora de Editar aparece as mensagens: http://micaelborin.com/sistema/editar.php?id=6 Segue o meu editar.php depois da modificação: <?php if(file_exists("init.php")) { require "init.php"; } else { echo "Arquivo init.php nao foi encontrado"; exit; } if(!function_exists("Abre_Conexao")) { echo "Erro o arquivo init.php foi auterado, nao existe a função Abre_Conexao"; exit; } $id = $_GET["id"]; Abre_Conexao(); $re = mysql_query("select count(*) as total from cadastro where id_usuario = $id"); $total = mysql_result($re, 0, "total"); ?> <!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=iso-8859-1" /> <title>Cadastro</title> <style> <!-- .textBox { border:1px solid gray; width:200px;} --> </style> </head> <body> <form id="form1" name="form1" method="post" action="salvar_edicao.php"> <input type="hidden" name="id" value="<?php echo $id; ?>" /> <table width="400" border="0" align="center"> <tr> <td width="145">Nome</td> <td width="245"><input name="nome" type="text" id="nome" maxlength="45" class="textBox" value="<?php echo $dados["nome"]; ?>" /></td> </tr> <tr> <td>Versão</td> <td><input name="versao" type="text" id="versao" maxlength="64" class="textBox" value="<?php echo $dados["versao"]; ?>" /></td> </tr> <tr> <td>Configuravel</td> <td><input name="configuravel" type="radio" value="S" <?php echo $dados["configuravel"] == "S" ? "checked=\"checked\"" : ""; ?> /><label>Sim</label> <input name="configuravel" type="radio" value="N" <?php echo $dados["configuravel"] == "N" ? "checked=\"checked\"" : ""; ?> /> <label>Não</label></td> </tr> <tr> <td>Descrição</td> <td><input name="descricao" type="text" id="descricao" maxlength="30" class="textBox" value="<?php echo $dados["descricao"]; ?>" /></td> </tr> <tr> <td>Tradução - Pt-br</td> <td><input name="traducao_ptbr" type="text" id="traducao_ptbr" maxlength="30" class="textBox" value="<?php echo $dados["traducao_ptbr"]; ?>"/></td> </tr> <tr> <td>Dificuldade</td> <td><input name="dificuldade" type="text" id="dificuldade" maxlength="20" class="textBox" value="<?php echo $dados["dificuldade"]; ?>"/></td> </tr> <tr> <td>Tempo</td> <td><input name="tempo" type="text" id="tempo" maxlength="45" class="textBox" value="<?php echo $dados["tempo"]; ?>"/></td> </tr> <tr> <td>Discussão em Português</td> <td><input name="disc_pt" type="text" id="disc_pt" maxlength="40" class="textBox" value="<?php echo $dados["disc_pt"]; ?>"/></td> </tr> <tr> <td>Discussão em Inglês</td> <td><input name="disc_en" type="text" id="disc_en" maxlength="10" class="textBox" value="<?php echo $dados["disc_en"]; ?>"/></td> </tr> <tr> <td>Download</td> <td><input name="download" type="text" id="download" maxlength="10" class="textBox" value="<?php echo $dados["download"]; ?>"/></td> </tr> <tr> <td> </td> <td><input type="submit" name="Submit" value="Salvar" style="cursor:pointer;" /></td> </tr> </table> </form> </body> </html> Obrigado pela atenção, Micael Compartilhar este post Link para o post Compartilhar em outros sites
Fabyo 66 Denunciar post Postado Julho 5, 2008 só copiar meu ultimo editar corretamente esta faltando no seu editar if($total == 1) { $re = mysql_query("select * from usuarios, estados where estados.id_estado = usuarios.fk_estado and usuarios.id_usuario = $id"); $dados = mysql_fetch_array($re); } Compartilhar este post Link para o post Compartilhar em outros sites
Balero 0 Denunciar post Postado Julho 6, 2008 Fabyo, eu alterei, só que agora aparece: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/micael/public_html/sistema/editar.php on line 22 Lembrando que eu não tenho a o campo Estados. Segue abaixo o arquivo editar.php: <?php if(file_exists("init.php")) { require "init.php"; } else { echo "Arquivo init.php nao foi encontrado"; exit; } if(!function_exists("Abre_Conexao")) { echo "Erro o arquivo init.php foi auterado, nao existe a função Abre_Conexao"; exit; } $id = $_GET["id"]; Abre_Conexao(); $re = mysql_query("select count(*) as total from cadastro where id_usuario = $id"); $total = mysql_result($re, 0, "total"); if($total == 1) { $re = mysql_query("select * from cadastro, cadastro where usuarios.id_usuario = $id"); $dados = mysql_fetch_array($re); } ?> <!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=iso-8859-1" /> <title>Cadastro</title> <style> <!-- .textBox { border:1px solid gray; width:200px;} --> </style> </head> <body> <form id="form1" name="form1" method="post" action="salvar_edicao.php"> <input type="hidden" name="id" value="<?php echo $id; ?>" /> <table width="400" border="0" align="center"> <tr> <td width="145">Nome</td> <td width="245"><input name="nome" type="text" id="nome" maxlength="45" class="textBox" value="<?php echo $dados["nome"]; ?>" /></td> </tr> <tr> <td>Versão</td> <td><input name="versao" type="text" id="versao" maxlength="64" class="textBox" value="<?php echo $dados["versao"]; ?>" /></td> </tr> <tr> <td>Configuravel</td> <td><input name="configuravel" type="radio" value="S" <?php echo $dados["configuravel"] == "S" ? "checked=\"checked\"" : ""; ?> /><label>Sim</label> <input name="configuravel" type="radio" value="N" <?php echo $dados["configuravel"] == "N" ? "checked=\"checked\"" : ""; ?> /> <label>Não</label></td> </tr> <tr> <td>Descrição</td> <td><input name="descricao" type="text" id="descricao" maxlength="30" class="textBox" value="<?php echo $dados["descricao"]; ?>" /></td> </tr> <tr> <td>Tradução - Pt-br</td> <td><input name="traducao_ptbr" type="text" id="traducao_ptbr" maxlength="30" class="textBox" value="<?php echo $dados["traducao_ptbr"]; ?>"/></td> </tr> <tr> <td>Dificuldade</td> <td><input name="dificuldade" type="text" id="dificuldade" maxlength="20" class="textBox" value="<?php echo $dados["dificuldade"]; ?>"/></td> </tr> <tr> <td>Tempo</td> <td><input name="tempo" type="text" id="tempo" maxlength="45" class="textBox" value="<?php echo $dados["tempo"]; ?>"/></td> </tr> <tr> <td>Discussão em Português</td> <td><input name="disc_pt" type="text" id="disc_pt" maxlength="40" class="textBox" value="<?php echo $dados["disc_pt"]; ?>"/></td> </tr> <tr> <td>Discussão em Inglês</td> <td><input name="disc_en" type="text" id="disc_en" maxlength="10" class="textBox" value="<?php echo $dados["disc_en"]; ?>"/></td> </tr> <tr> <td>Download</td> <td><input name="download" type="text" id="download" maxlength="10" class="textBox" value="<?php echo $dados["download"]; ?>"/></td> </tr> <tr> <td> </td> <td><input type="submit" name="Submit" value="Salvar" style="cursor:pointer;" /></td> </tr> </table> </form> </body> </html> Segue também uma imagem do meu phpMyAdmin: Obrigado, Micael Compartilhar este post Link para o post Compartilhar em outros sites
Tilo 0 Denunciar post Postado Julho 10, 2008 Eae, beleza? nem sei se alguem vai me responder mais naum custa nada tentar! exclui os seguintes campos: da tabela Usuarios Preferencias Salario Login Senha Os mesmos itens no cadastro.php e no salvar.php porem, quando vou postar ele dá o seguinte erro! *Erro nao foi possivel efetuar o cadastro* o que pode estar acontecendo? já tentei de tudo, até excluir um por um, sempre dá erro! Compartilhar este post Link para o post Compartilhar em outros sites
Alaerte Gabriel 662 Denunciar post Postado Julho 10, 2008 Tu excluiu ? se tu exclui os campo, vai cadastrar os dados nele como ? Compartilhar este post Link para o post Compartilhar em outros sites
Jean michel 0 Denunciar post Postado Julho 15, 2008 ola Fabyo. estou com esse problema aqui! Parse error: syntax error, unexpected T_DNUMBER in /home/a5838727/public_html/init.php on line 37 o que tenho q fazer ? para ser sincero to com muitas duvias pois sou novo nisso! Como eu configuro o init , tabela e config ? Eu hospedo em domínio free. eu tenho o usuário e senha do mysql e um servidor que eles me dão! estou com duvida sobre a linha BANCO não sei o que colocar no lugar dela! você poderia montar esses 3 como um exemplo para mim ? desculpe mas sou muito novo e isto é realmente o que estou procurando! fico grato desde já Compartilhar este post Link para o post Compartilhar em outros sites
Jean michel 0 Denunciar post Postado Julho 15, 2008 o site me ofereceu tbm database isso é para substituir pelo "BANCO" obs: o data base é igual o meu user ! Compartilhar este post Link para o post Compartilhar em outros sites
fox_hound 0 Denunciar post Postado Julho 15, 2008 muito bom mesmo http://forum.imasters.com.br/public/style_emoticons/default/clap.gif ps: preciso usar mais funções nos meus codigos http://forum.imasters.com.br/public/style_emoticons/default/blush.gif Compartilhar este post Link para o post Compartilhar em outros sites
Jean michel 0 Denunciar post Postado Julho 15, 2008 se puder me ajudar fico grato! Compartilhar este post Link para o post Compartilhar em outros sites
Alaerte Gabriel 662 Denunciar post Postado Julho 18, 2008 Isso é erro de sintaxe amigo, procure na linha 37 ou 36 no arquivo init.php o problema. Leia também sobre tratamento de erros: http://forum.imasters.com.br/public/style_emoticons/default/seta.gif http://forum.imasters.com.br/index.php?showtopic=229485 Compartilhar este post Link para o post Compartilhar em outros sites
Von_Reibnitz 0 Denunciar post Postado Julho 20, 2008 bem, muito bom e bem feito o sistema, mas ao tentar modificar ele não cadastraaparecendo a mensagem que não foi possível cadastrar. seguem os arquivos que eu alterei: Cadastro.php CODE <!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=iso-8859-1" /> <title>Cadastro</title> <style> <!-- .textBox { border:1px solid gray; width:200px;} --> </style> <link href="estilo.css" rel="stylesheet" type="text/css" /> </head> <body> <form id="form1" name="form1" method="post" action="salvar.php"> <table width="400" align="center"> <tr> <td width="145">Nome</td> <td width="245"><input name="nome" type="text" id="nome" maxlength="45" class="textBox" /></td> </tr> <tr> <td>Sobrenome</td> <td><input name="sobre" type="text" id="sobre" maxlength="64" class="textBox" /></td> </tr> <tr> <td>Sexo</td> <td><input name="sexo" type="radio" value="M" checked="checked" /> <label>Masculino</label> <input name="sexo" type="radio" value="F" /> <label>Feminino</label></td> </tr> <tr> <td><div align="left">Data Nascimento</div></td> <td><input name="dia" class="input" size="2" maxlength="2" /> / <input name="mes" class="input" size="2" maxlength="2" /> / <input name="ano" class="input" size="5" maxlength="4" /> dd/mm/aaaa</td> </tr> <tr> <td><div align="left">Data Falecimento</div></td> <td><input name="dia2" class="input" size="2" maxlength="2" id="dia2" /> / <input name="mes2" class="input" size="2" maxlength="2" id="mes2" /> / <input name="ano2" class="input" size="5" maxlength="4" id="ano2" /> dd/mm/aaaa </td> </tr> <tr> <td>Cidade</td> <td><input name="cidade" type="text" id="cidade" maxlength="45" class="textBox" /></td> </tr> <tr> <td>Estado</td> <td><input name="estado" type="text" id="estado" maxlength="45" class="textBox" /></td> </tr> <tr> <td> </td> <td><input type="submit" name="Submit" value="Salvar" style="cursor:pointer;" /></td> </tr> </table> </form> </body> </html> salvar.php CODE <?php if($_SERVER["REQUEST_METHOD"] == "POST") { $nome = $_POST["nome"]; $sobre = $_POST["sobre"]; $sexo = $_POST["sexo"]; $data_nasc = "$_POST[ano]-$_POST[mes]-$_POST[dia]"; $data_falec = "$_POST[ano2]-$_POST[mes2]-$_POST[dia2]"; $cidade = $_POST["cidade"]; $estado = $_POST["estado"]; include "config.php"; if(@mysql_query("INSERT INTO obitos VALUES ('$nome', '$sobre', '$sexo' , '$data_nasc', '$data_falec', '$cidade', '$estado' )")) { if(mysql_affected_rows() == 1){ echo "Registro efetuado com sucesso<br />"; } } else { if(mysql_errno() == 1062) { echo $erros[mysql_errno()]; exit; } else { echo "Erro nao foi possivel efetuar o cadastro"; exit; } @mysql_close(); } } ?> <a href="index.html">Voltar</a> é um erro duplicar as datas? se sim como incluir outra opção como data de falecimento e nascimento? agradeço o auxílio se possível Compartilhar este post Link para o post Compartilhar em outros sites
fabaosalles 0 Denunciar post Postado Julho 29, 2008 alguem me diz aew como eu posso usar esse onda com o wamp ...? eh q eu sou novo ainda nessas ondas... e um amigo meu disse pra eu usar esse wamp... por favor abraçosss Compartilhar este post Link para o post Compartilhar em outros sites
brunommoraes 0 Denunciar post Postado Agosto 1, 2008 Fabyo, Achei seu tópico muito bom mas não consegui baixar o arquivo cadastro.zip. Há algum problema? Obrigado. Compartilhar este post Link para o post Compartilhar em outros sites
BRUNO AMABILE 0 Denunciar post Postado Agosto 11, 2008 Valeu Fabyo!!!!!!!!!! Cara... você nao tem noçao o quanto me ajudou, se todo mundo fizesse que nem você... Parabens mesmo!! Compartilhar este post Link para o post Compartilhar em outros sites
K4B4L4 0 Denunciar post Postado Agosto 11, 2008 Muito bom o tutorial! Parabéns!!! Me ajudou a entender algumas coisas que ficava sempre em dúvida. Vlw Compartilhar este post Link para o post Compartilhar em outros sites
Fabio Toshiyuki 0 Denunciar post Postado Setembro 13, 2008 Estou começando a aprender PHP, e estava procurando algo como esse tutarial faz um tempinho já.. muito bom.. Parabéns! Compartilhar este post Link para o post Compartilhar em outros sites
vangon 0 Denunciar post Postado Novembro 20, 2008 Parabés Fabyo pelo seu tópico, nele conseguir ver que tem muitas funções para se estudar... Só posso dizer uma coisa, continue assim cara vai chegar longe... Espero um dia estar postando algum artigo que ajude a galera tambem... Estou começando agora com php e estou aprendendo muito aqui no forum com pessoas como você. Compartilhar este post Link para o post Compartilhar em outros sites