System with problems in hosting, but on the computer runs perfect

Asked

Viewed 25 times

-2

Good evening, person! So I created a login system and protected pages per session. I tested the system on my computer and it is working perfectly. It runs all right (both the login area and the sessions. It turns out that when I run the same system in the hosting it just gives error. For example, when I log in (at the hosting) it doesn’t redirect contributors to the.php page, it simply stops at the.php validator page where it shows the message of the connection to the database. Restricted pages are unprotected because the sessions are not working. The code of the validated page is this. Please help me, for God’s sake!

<?php
    session_start(); 
        //Incluindo a conexão com banco de dados   
    include_once("conexao.php");    
    //O campo usuário e senha preenchido entra no if para validar
    if((isset($_POST['email'])) && (isset($_POST['senha']))){
        $usuario = mysqli_real_escape_string($conn, $_POST['email']); //Escapar de caracteres especiais, como aspas, prevenindo SQL injection
        $senha = mysqli_real_escape_string($conn, $_POST['senha']);
        $senha = md5($senha);
            
        //Buscar na tabela usuario o usuário que corresponde com os dados digitado no formulário
        $result_usuario = "SELECT * FROM usuarios WHERE email = '$usuario' && senha = '$senha' LIMIT 1";
        $resultado_usuario = mysqli_query($conn, $result_usuario);
        $resultado = mysqli_fetch_assoc($resultado_usuario);
        
        //Encontrado um usuario na tabela usuário com os mesmos dados digitado no formulário
        if(isset($resultado)){
            $_SESSION['usuarioId'] = $resultado['id'];
            $_SESSION['usuarioNome'] = $resultado['nome'];
            $_SESSION['usuarioNiveisAcessoId'] = $resultado['niveis_acesso_id'];
            $_SESSION['usuarioEmail'] = $resultado['email'];
            if($_SESSION['usuarioNiveisAcessoId'] == "1"){
                header("Location: administrativo.php");
            }elseif($_SESSION['usuarioNiveisAcessoId'] == "2"){
                header("Location: colaborador.php");
            }else{
                header("Location: cliente.php");
            }
        //Não foi encontrado um usuario na tabela usuário com os mesmos dados digitado no formulário
        //redireciona o usuario para a página de login
        }else{    
            //Váriavel global recebendo a mensagem de erro
            $_SESSION['loginErro'] = "Usuário ou senha Inválido";
            header("Location: ../home/index.php");
        }
    //O campo usuário e senha não preenchido entra no else e redireciona o usuário para a página de login
    }else{
        $_SESSION['loginErro'] = "Usuário ou senha inválido";
        header("Location: ../home/index.php");
    }
?>
  • What error was generated?

  • Friend, offline login system, restricted pages with sessions work perfectly. Already in hosting gives problem.

  • Warning: Cannot Modify header information - headers already sent by (output Started at /home/ggcuhl58/public_html/Siva/conexao.php:14) in /home/ggcuhl58/public_html/Siva/valida.php on line 25

  • Warning: session_start(): Unable to log in when headers already sent in /home/j7vtmuvx/public_html/Siva/register-vaccinated/Protect.php at line 8 Warning: Cannot modify header information - headers already sent by (output started in /home/j7vtmuvx/public_html/Siva/register-vaccinated/index.php:1) in /home/j7vtmuvx/public_html/Siva/register-vaccinated/Protect.php on line 11

  • 1

    take a look at this post... https://answall.com/questions/4251/erro-cannot-modify-header-information-headers-already-sent

No answers

Browser other questions tagged

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