Jump to content

Após validar o login, ele não está redirecionando para a outra página


GSantos

Recommended Posts


Eu queria depois de validar o login para redirecionar para a página dependendo do nível de acesso, agradeceria que alguem me ajudasse o mais rápido possível, obrigado

aqui está a página de login de validação:

<?php

session_start();

include ("config.php");

if(isset($_POST['submit'])){

   $Nmutilizador = mysqli_real_escape_string($conn, $_POST['username']);
   $pass = md5($_POST['Password']);
   $lvlacesso = $_POST['NivelAcesso'];

   $select = " SELECT * 
                FROM users 
                WHERE NmUtilizador = '$Nmutilizador' 
                && PalavraPasse = '$pass' ";

   $result = mysqli_query($conn, $select);

   if(mysqli_num_rows($result) > 0){
        $row = mysqli_fetch_array($result);

        if ($_SESSION['NivelAcesso'] == '1') { 
            // check the value of the 'status' in the db
            //go to admin area
            header("Location: indexadmin.php");
        } else {
            //go to members area
            header("Location: indexposlogin.php");  
        }
     
   }else{
      $error[] = 'incorrect email or password!';
   }
};
?>


pagina de login:

<?php

    session_start();

echo '<!doctype html>
<html lang="en">
  <head>
      <title>Página de Login</title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

    <link href="https://fonts.googleapis.com/css?family=Lato:300,400,700&display=swap" rel="stylesheet">

    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
    
    <link rel="stylesheet" href="css/stylelogin.css">
    
    <style>
        h3{
            text-align: center;
        }
        
        .disclaimer{
            visibility: hidden;
        }
    </style>

    </head>
    <body>
    <section class="ftco-section">
        <div class="container">
            <div class="row justify-content-center">
                <div class="col-md-6 text-center mb-5">
                    <h2 class="heading-section">Inicie sessão</h2>
                </div>
            </div>
            <div class="row justify-content-center">
                <div class="col-md-7 col-lg-5">
                    <div class="wrap">
                        <div class="img" style="background-image: url(Imagens/imagemlogin.png);"></div>
                        <div class="login-wrap p-4 p-md-5">
                      <div class="d-flex">
                          <div class="w-100">
                              <h3 class="mb-4">Login</h3>
                          </div>
                      </div>
                            <form action="validalogin.php" class="signin-form">
                          <div class="form-group mt-3">
                              <input name="username" type="text" class="form-control" required>
                            <label class="form-control-placeholder" for="username">Nome de Utilizador</label>
                          </div>
                    <div class="form-group">
                      <input name="pass" id="password-field" type="password" class="form-control" required>
                      <label class="form-control-placeholder" for="password">Palavra-Passe</label>
                      <span toggle="#password-field" class="fa fa-fw fa-eye field-icon toggle-password"></span>
                    </div>
                    <div class="form-group">
                        <button type="submit" class="form-control btn btn-primary rounded submit px-3">Entrar</button>
                    </div>
                    <div class="form-group d-md-flex">
                        <div class="w-50 text-left">
                            <label class="checkbox-wrap checkbox-primary mb-0">Lembrar me
                                      <input type="checkbox" checked>
                                      <span class="checkmark"></span>
                                        </label>
                                    </div>
                                    <div class="w-50 text-md-right">
                                        <a href="#">Esqueci me da palavra-passe</a>
                                    </div>
                    </div>
                  </form>
                  <p class="text-center">Não és membro?  <a data-toggle="tab" href="registar.php">Registar me</a></p>
                  <p class="text-center"><a data-toggle="tab" href="https://ingamept.000webhostapp.com/">Voltar</a></p>
                </div>
              </div>
                </div>
            </div>
        </div>
    </section>

    <script src="js/jquery.min.js"></script>
  <script src="js/popper.js"></script>
  <script src="js/bootstrap.min.js"></script>
  <script src="js/main.js"></script>

    </body>
</html>
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.