Ir para conteúdo
Fórum Script Brasil

alexnuvi

Membros
  • Total de itens

    5
  • Registro em

  • Última visita

Tudo que alexnuvi postou

  1. Senhores, Saudações! Comecei a escrever um codigo que altera a senha dos usuário que estiverem logados em meu site, o problema é que não esta alterando a senha quando digito os dados para alterar, e não retorna nenhuma mensagem de erro, abaixo segue o codigo: Não consegui encontrar algum erro olhando o codigo, gostaria da ajuda de voces para fazer o codigo funcionar. Pagina que o usuário visualiza: <?php //Inicia a sessão session_start(); //Verifica se há dados ativos na sessão if(empty($_SESSION["id"]) || empty($_SESSION["nome"]) || empty($_SESSION["login"])) { //Caso não exista dados registrados, exige login header("Location:../login.php"); } ?> <html> <head> <title>Edificio</title> <link href="../estilo.css" rel="stylesheet" type="text/css" /> <head> </head> <body> <div id="tudo"> <div id="conteudo"> <div id="cabecamenu">&nbsp; São Vicente - <script language=javascript src="../hora.js"></SCRIPT> </div> <table border="0" cellspacing="0" cellpadding="0" id="imagem"> <tr> <td> <div id="imagem"><img src="../imagens/logo1.jpg" width="150px" height="150"><img src="../imagens/inst.jpg"></div> </td> </tr> </table> <div id="loginmenu"> </div> <!-- Menu --> <table border="0"cellspacing="0" cellpadding="0" valign="top"> <tr> <td > <UL id="nav"> <LI><A href="./index.php">Pagina Inicial</A></LI> <LI><A href="./condominio.php">O Condomínio</A> </LI> <LI><A href="../cadastro.php">Cadastro </A> </LI> <LI><A href="./comunicado.php">Comunicados</A> </LI> <LI><A href="#">Prestando Contas</A></LI> <LI><A href="#">Links e telefones uteis</A></LI> <LI><A href="#">Galeria de Fotos</A></LI> <LI><A href="#">Corpo Diretivo</A></LI> <LI><A href="#">Funcionários</A></LI> <LI><A href="./contato.php">Fale com o Síndico</A></LI> </UL> </td> <td width="100%" valign="top"> <div id="boxint"><h1>Alterar Senha:</h1> <font face="verdana" size="2"> <p class="justify"> <form action="alterar_senha.php" method="post" enctype="multipart/form-data" name="form_alterar_senha"> <table border="0" width="400px"><tr><td> <span class="texto">Nova Senha:</span><br> <input name="senha" type="text" class="formulario" size="35" value=""> <span class="asterisco">*</span> <br><br> <span class="texto">Repetir Nova Senha:</span><br> <span class="ext"></span><input name="rep_senha" type="text" class="formulario" size="35" value="">&nbsp; <span class="asterisco">*</span> &nbsp; <span class="texto"></span> <br><br> <br><br> <input name="Alterar" type="submit" class="form" value="Alterar"></div> </td> </tr> </table> </form> </font> </div> </td> <td valign="top"><table border="0" align="right" class="borda_acesso"> <form action="auth.php" name="autenticacao" method="post"> <tr> <td bgcolor="#ffffff"><span class="acesso"> Logado como:</span></td> </tr> <tr> <td><span class="tlogin">Nome: <strong><?php echo $_SESSION['nome'] ?></strong></span></td></tr> <tr> <td><span class="tlogin">Login: <strong><?php echo $_SESSION['login'] ?></strong></span></td></tr> <tr> <td width="140"><span class="tlogin">Apartamento: <strong><?php echo $_SESSION['apto'] ?></strong></span></td> </tr> <tr> <td><span class="tlogin">Email:<strong><?php echo $_SESSION['email'] ?></strong></span></td> </tr> <tr> <td><br><a href="#" class="acesso_link"><img src="../imagens/edit.png" class="imgs">&nbsp;Atualizar dados.</a></td></tr> <tr> <td><a href="#" class="acesso_link" alt="Sair"><img src="../imagens/senha.jpg" class="imgs">&nbsp;Alterar Senha</a></td></tr> <tr> <td><a href="../destroy.php" class="acesso_link" alt="Sair"><img src="../imagens/logoof.gif" class="imgs">&nbsp;Sair</a></td></tr> </table> </td> </tr> <tr> <td><table> <tr> <td align="center"><span class="site">Reciclagem do lixo.</span></td> </tr> <tr> <td><img width="150px"src="../imagens/reciclagem.jpg"></td> </tr> <tr> <td align="center"><span class="site">clique e saiba mais.</span></td> </tr> </table> </td> <td> </td> <td> </td> </tr> </table><br> <br> </div> <div id="rodape">Sonho Meu © Todos os direitos reservados</br> Rua: Padre Anchieta, 181 S&atilde;o Vicente - SP<br> Fone: (13)1234-5678 </div> </div> </body> </html> Pagina PHP que faz a alteração da senha e recebe os dados do formulario: <?php //Inicia a sessão session_start(); //Verifica se há dados ativos na sessão if(empty($_SESSION["id"]) || empty($_SESSION["nome"]) || empty($_SESSION["login"])) { //Caso não exista dados registrados, exige login header("Location:../login.php"); } include "../config.php"; // recebe dados do formulario $senha = $_POST['senha']; $rep_senha = $_POST['rep_senha']; // verifica se o usuario digitou a senha if($senha == "") { echo "<font color=red><b> Digite sua senha! $login </font></b>"; exit; } else { // se ele digitou vamos comparar if($senha != $rep_senha) { echo "<font color=red><b> Senha invalida! </font></b>"; exit; } } // altera a senha $consulta = mysql_query("update usuarios set senha = '$senha' where login = '$login'"); // verifica se foi alterada a senha if($consulta) { $msg = urlencode("Senha alterada com sucesso!"); header("Location: ../maraba/index.php?msg=$msg"); exit; } else { $erro = urlencode("Não foi possivel alterar a senha!"); header ("Location: ../maraba/index.php?erro=$erro"); exit; } ?> Espero que consgigam me ajudar, pois passei horas e não consegui resolver. Obrigado.
  2. Consegui corrigir ! Obrigado pelas dicas. Reescrevi varias partes do codigo customizando a bagaça.... rs valeu....
  3. Senhores, Saudações! Criei um sistema para lembrar senha, e quando tento executar da uns erros que não estou conseguindo resolver. O sistema consiste em 3 paginas: lembrar_senha.php pergunta_secreta.php mostrar_senha.php E funciona respectivamente na ordem acima. Na pagina "lembrar_senha.php" o usuario informa seu login no sistema e passa para a segunda pagina "pergunta_secreta.php" se os dados estiverem corretos a pagina mostrar_senha exibe a senha do usuário. Segue os codigos: lembrar_senha.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=iso-8859-1" /> <title>Untitled Document</title> <style type="text/css"> <!-- .style1 {font-size: 36px} .style2 { color: #000000; font-weight: bold; } .style3 { color: #FFFFFF; font-weight: bold; } --> </style> </head> <body> <form action="pergunta_secreta.php" method="post" enctype="multipart/form-data" name="formlembrar"> Lembrar senha<br><br> Digite seu login aqui por favor!<br><br> login: <label for="textfield"></label> <input name="login" type="text" id="login" size="35" maxlength="200" /></td> <label for="Submit"></label> <input type="submit" name="Verificar" value="Verificar" id="Verificar" /> </form> </body> </html> Até aqui ok, não exibe nenhum erro. pergunta_secreta.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=iso-8859-1" /> <title>Untitled Document</title> <style type="text/css"> <!-- .style1 {font-size: 36px} .style2 { color: #000000; font-weight: bold; } .style3 {color: #FFFFFF; font-weight: bold; } .style4 {color: #FFFFFF} --> </style> </head> <body> <form action="mostrar_senha.php" method="post" enctype="multipart/form-data" name="formmostar"> Digite seus dados!<br><br> <?php // inclui o arquivo de configuração do sistema include "./config.php"; // recebe dados do formulario $login = htmlspecialchars($_POST['login']); // faz consulta no banco de dados $consulta = mysql_query("select * from usuarios where login = '$login'"); // imprime a pergunta do usuario while($linha = mysql_fetch_object($consulta)) { echo "<b>".$linha->email."?</b>"; } ?> <br><br> <!--DWLayoutEmptyCell-->&nbsp;</td> Email: <label for="textfield"></label> <input name="resposta" type="text" id="resposta" size="40" maxlength="200" /> <strong>Login:</strong> <label for="textfield"></label> <input name="login" type="text" id="login" size="40" maxlength="200" /> <label for="Submit"></label> <input type="submit" name="mostar" value="Mostrar" id="mostrar" /> </form> </body> </html> Quando a pagina acima é exibida retorna o seguinte erro: Warning: mysql_fetch_object(): supplied argument is not a valid MySQL result resource in C:\wamp\www\maraba\senha\pergunta_secreta.php on line 36 mostrar_senha.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=iso-8859-1" /> <title>Untitled Document</title> <style type="text/css"> <!-- .style1 { color: #000000; font-weight: bold; } .style2 {font-size: 36px} .style3 { color: #FFFFFF; font-weight: bold; } --> </style> </head> <body> <form action="../logar.php" method="post" enctype="multipart/form-data" name="form_mostra_senha"> Mostrar senha <br> <a href="../index.php" class="style1">Home</a> <?php // inclui o arquivo de configuração do sistema include "./config.php"; // recebe dados do formulario $login = htmlspecialchars($_POST['login']); $email = htmlspecialchars($_POST['email']); // faz consulta no banco de dados $consulta = mysql_query("select * from dados_usuarios where Login = '$login'"); // imprime dados do usuario while($linha = mysql_fetch_object($consulta)) { verifica se a resposta é verdadeira if($resposta == $linha->email) { ?> <table width="100%" border="2" bordercolor="#FFFFFF" cellpadding="0" cellspacing="0"> <!--DWLayoutTable--> <tr> <td width="130" height="24" align="right" valign="middle" bgcolor="#000000"><span class="style3">Login:</span></td> <td colspan="3" valign="middle" bgcolor="#CCCCCC"><label for="textfield"></label> <input name="login" type="text" id="login" value="<?php echo $linha->Login;?>" size="40" maxlength="200" /></td> </tr> <tr> <td height="24" align="right" valign="middle" bgcolor="#000000" class="style3">Senha:</td> <td colspan="3" valign="middle" bgcolor="#CCCCCC"><label for="label"></label> <input name="senha" type="text" id="label" value="<?php echo $linha->Senha;?>" size="20" /></td> </tr> <tr> <td height="24" align="right" valign="middle" bgcolor="#000000" class="style3">Nome:</td> <td colspan="3" valign="middle" bgcolor="#CCCCCC"><label for="label2"></label> <input name="nome" type="text" id="label2" value="<?php echo $linha->Nome;?>" size="40" maxlength="200" /></td> </tr> <tr> <td height="24" align="right" valign="middle" bgcolor="#000000" class="style3">E-mail:</td> <td colspan="3" valign="middle" bgcolor="#CCCCCC"><label for="label3"></label> <input name="email" type="text" id="label3" value="<?php echo $linha->Email;?>" size="40" maxlength="200" /></td> </tr> <tr> <td height="26">&nbsp;</td> <td width="66">&nbsp;</td> <td width="48" valign="top"><label for="Submit"></label> <input type="submit" name="logar" value="Logar" id="logar" /></td> <td width="127">&nbsp;</td> </tr> </table> <?php } else { echo "<font color=red><b> Sua resposta esta errada! </font></b>"; exit; } } ?> </td> <td>&nbsp;</td> </tr> <tr> <td height="100">&nbsp;</td> <td>&nbsp;</td> <td>&nbsp;</td> <td>&nbsp;</td> <td>&nbsp;</td> <td>&nbsp;</td> <td>&nbsp;</td> <td>&nbsp;</td> </tr> </table> </form> </body> </html> E na pagina mostrar_senha.php retorna o seguinte erro: Parse error: syntax error, unexpected T_STRING in C:\wamp\www\maraba\senha\mostrar_senha.php on line 40 minha tabela esta estrurada da seguinte forma: mysql> desc usuarios; +-------+-------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +-------+-------------+------+-----+---------+----------------+ | id | int(11) | NO | PRI | NULL | auto_increment | | nome | varchar(50) | NO | | | | | email | varchar(60) | NO | | | | | login | varchar(20) | NO | | | | | senha | varchar(8) | NO | | | | +-------+-------------+------+-----+---------+----------------+ 5 rows in set (0.02 sec) mysql> Agradeço a ajuda e fico ao dispor se não fui muito claro. Obrigado
  4. ESerra, Muito obrigado! Funcionou do jeito que voce me passou.
  5. Senhores, Saudações, Sou novo em PHP e gostaria de resolver um problema. Estou tentando adicionar uma lógica a o meu site quero que apareça um determinado link quando o usuário estiver logado. Estou fazendo assim mas não funciona: <? PHP if(isset($_SESSION["nome"]==["alex"])) echo "<a href='../cms/index.html'>clique aqui para adiministrar</a>"; ?> Gostaria que o link apareça apenas quando o usuário alex estiver logado, se o for outro usuário não aparece nada. Estou usando MySql e minha tabela esta estruturada sa seguinte forma: mysql> desc usuarios; +-------+-------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +-------+-------------+------+-----+---------+----------------+ | id | int(11) | NO | PRI | NULL | auto_increment | | nome | varchar(50) | NO | | | | | email | varchar(60) | NO | | | | | login | varchar(20) | NO | | | | | senha | varchar(8) | NO | | | | +-------+-------------+------+-----+---------+----------------+ Obrigado. :unsure: Alex
×
×
  • Criar Novo...