E-mail is not being true

Asked

Viewed 51 times

3

I have a problem: I’m creating a field "forgot password", where the user enters the email and if it is in the database appears as true and redirects to the page teste.php; otherwise for the page index.php.

However, when I click the button recuperar, goes to the page index.php regardless of whether it was true or not. Follow the code:

<?php
session_start();

include_once("../conn/conexao.php");//faz a conexao com o banco de dados
$entrar = filter_input(INPUT_POST, 'recuperar', FILTER_SANITIZE_STRING); //aqui se colocar o nome do botão que fara com que entre
if($entrar){
      $ub = filter_input(INPUT_POST, 'email', FILTER_SANITIZE_STRING);//aqui se coloca o nome que pegara no banco para fazer o login


    if((!empty($ub)) AND (!empty($ub))){
        $result_usuario = "SELECT * FROM tb_usuario WHERE email='$ub' LIMIT 1";//aqui pegara o usuario no banco de dados
        $resultado_usuario = mysqli_query($conexao, $result_usuario) or die (mysqli_error($conexao));
            if($resultado_usuario){
            $row_usuario = mysqli_fetch_array($resultado_usuario);
            if($ub== $row_usuario['email']){

                $_SESSION['email'] = $row_usuario['email'];


                if($row_usuario['email']==1){

                header("Location:teste.php");
                }
                else{
                header("Location:index.php");
                }   
                exit; 
            }
            }
    }
}
?>

<!DOCTYPE html>
<html lang="pt-br">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- As 3 meta tags acima *devem* vir em primeiro lugar dentro do `head`; qualquer outro conteúdo deve vir *após* essas tags -->
    <title>Lance Web</title>
    <!-- Bootstrap -->
    <link href="../bootstrap/css/bootstrap.min.css" rel="stylesheet">
    <!-- HTML5 shim e Respond.js para suporte no IE8 de elementos HTML5 e media queries -->
    <!-- ALERTA: Respond.js não funciona se você visualizar uma página file:// -->
    <!--[if lt IE 9]>
      <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
      <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
    <style type="text/css">
        /*Aqui deixa a imagem de fundo responsiva*/
        body{ 
            background-color:#0A8AF5;
        }

        /*Aqui se edita o icone de login e senha*/
        #caixaemail{
            padding-left:24px;
            line-height:16px;
            background-position:2px center;
            background-repeat:no-repeat;
            background-image:url(../img/login.png);
        }

        #caixasenha{
            padding-left:24px;
            line-height:16px;
            background-position:2px center;
            background-repeat:no-repeat;
            background-image:url(../img/senha.png);
        }

    </style>
  </head>
  <body>
    <div class="container" align="center">
        <img src="../img/logomarca.png" class="img-responsive"><br><br><br>
            <form action="" method="post" class="form-signin" role="form">
                <div class="col-md-4 col-md-offset-4">
                    <input type="email" class="form-control" id="caixaemail" placeholder="Digite seu email" required autofocus name="email"><br>
                    <button class="btn btn-lg btn-primary btn-block" type="submit" name="recuperar" value="recuperar">Recuperar</button><br>
                </div><!-- fim da div col que centraliza -->
            </form><!-- fim formulario -->
                <div class="col-md-4 col-md-offset-4">
                    <a href="../index.php"><button class="btn btn-lg btn-danger btn-block">Voltar</button></a>
                </div><!-- fim da div col que centraliza -->            
    </div><!-- fim div class container responsiva -->

    <!-- jQuery (obrigatório para plugins JavaScript do Bootstrap) -->
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
    <!-- Inclui todos os plugins compilados (abaixo), ou inclua arquivos separadados se necessário -->
    <script src="bootstrap/js/bootstrap.min.js"></script>
  </body>
</html>
  • the question got wrong rs

  • Kkk concertei..

  • solved, created an email session and compared with the typed one...

  • if($row_usuario['email']=$email){

  • So delete the question

  • @Dvd or else puts as answer what you have done if someone comes across a problem similar to this

  • @Jeffersonquesado It was Ap that solved. See the comments above. Either he deletes the question or he puts an answer.

  • @Dvd and my comment was a criticism of his request for exclusion ;-) Ok, I tried to omit the agent but ended up making us literary confusion. Might as well have been read as "answer what’s been done," pardon

  • More on the subject of self-response: https://pt.meta.stackoverflow.com/q/4436/64969

  • 3

    @pherb let’s give a check-mate on this question? Put your solution in an answer and after about 15 minutes you mark it as right. It’s gonna be a ball show! ;)

  • 1

    I answered with the answer guys, only I can only mark the answer with the right V after 2 days :/

  • 1

    @I was gonna tell you what pherb said up there. The system has a rule that if you want to accept your own answer, it must be at least two days after the question has been posted. I’m not sure what the motivation of that rule is, but it does exist.

Show 7 more comments

1 answer

1


You start an e-mail session:

$email = $_SESSION['email'];

And in the if and else, instead of comparing with ==1 you compare with the variable of SESSION:

if($row_usuario['email']==$email){ //...

Browser other questions tagged

You are not signed in. Login or sign up in order to post.