Ir para conteúdo
Fórum Script Brasil
  • 0

Erro sistema para lembrar senha


alexnuvi

Pergunta

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

Link para o comentário
Compartilhar em outros sites

2 respostass a esta questão

Posts Recomendados

  • 0

o primeiro erro não deve estar recebendo o $_post["login"]

veja se esta recebendo coloque um echo para ver o que cria na sua query:

// recebe dados do formulario

$login = htmlspecialchars($_POST['login']);

echo "select * from usuarios where login = '$login'";

exit;

// faz consulta no banco de dados

$consulta = mysql_query("select * from usuarios where login = '$login'");

neste segundo logo abaixo do while coloque comentario

Onde tem

verifica se a resposta é verdadeira

Fica:

//verifica se a resposta é verdadeira

Link para o comentário
Compartilhar em outros sites

  • 0
o primeiro erro não deve estar recebendo o $_post["login"]

veja se esta recebendo coloque um echo para ver o que cria na sua query:

// recebe dados do formulario

$login = htmlspecialchars($_POST['login']);

echo "select * from usuarios where login = '$login'";

exit;

// faz consulta no banco de dados

$consulta = mysql_query("select * from usuarios where login = '$login'");

neste segundo logo abaixo do while coloque comentario

Onde tem

verifica se a resposta é verdadeira

Fica:

//verifica se a resposta é verdadeira

Consegui corrigir !

Obrigado pelas dicas.

Reescrevi varias partes do codigo customizando a bagaça.... rs

valeu....

Link para o comentário
Compartilhar em outros sites

Participe da discussão

Você pode postar agora e se registrar depois. Se você já tem uma conta, acesse agora para postar com sua conta.

Visitante
Responder esta pergunta...

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emoticons são permitidos.

×   Seu link foi incorporado automaticamente.   Exibir como um link em vez disso

×   Seu conteúdo anterior foi restaurado.   Limpar Editor

×   Você não pode colar imagens diretamente. Carregar ou inserir imagens do URL.



  • Estatísticas dos Fóruns

    • Tópicos
      152,1k
    • Posts
      651,8k
×
×
  • Criar Novo...