Problem session_start

0

Help I have a problem with the following php script. The error is detailed when uploading the script to the internet, in the local server it works without problem.

I find the following error:

I appreciate the help.

This is my php code.

<?php

class Ingreso{

public function ingresoController(){

    if(isset($_POST["usuarioIngreso"])){

        if(preg_match('/^[a-zA-Z0-9]+$/', $_POST["usuarioIngreso"])&&
           preg_match('/^[a-zA-Z0-9]+$/', $_POST["passwordIngreso"])){

            #$encriptar = crypt($_POST["passwordIngreso"], '$2a$07$asxx54ahjppf45sd87a5a4dDDGsystemdev$');

            $datosController = array("usuario"=>$_POST["usuarioIngreso"],
                                 "password"=>$_POST["passwordIngreso"]);

            $respuesta = IngresoModels::ingresoModel($datosController, "usuarios");

            $intentos = $respuesta["intentos"];
            $usuarioActual = $_POST["usuarioIngreso"];
            $maximoIntentos = 2;

            if($intentos < $maximoIntentos){

                if($respuesta["usuario"] == $_POST["usuarioIngreso"] && $respuesta["password"] == $_POST["passwordIngreso"]){

                    $intentos = 0;

                    $datosController = array("usuarioActual"=>$usuarioActual, "actualizarIntentos"=>$intentos);

                    $respuestaActualizarIntentos = IngresoModels::intentosModel($datosController, "usuarios");

                    session_start();

                    $_SESSION["validar"] = true;
                    $_SESSION["usuario"] = $respuesta["usuario"];
                    $_SESSION["nombre"] = $respuesta["nombre"];
                    $_SESSION["id_us"] = $respuesta["id_us"];
                    $_SESSION["rol"] = $respuesta["rol"];
                    //$_SESSION["photo"] = $respuesta["photo"];*/
                    // $_SESSION["password"] = $respuesta["password"];
                    // $_SESSION["email"] = $respuesta["email"];


                    header("location:eventos");

                }

                else{

                    ++$intentos;

                    $datosController = array("usuarioActual"=>$usuarioActual, "actualizarIntentos"=>$intentos);

                    $respuestaActualizarIntentos = IngresoModels::intentosModel($datosController, "usuarios");

                    echo '<div class="alert alert-danger">4 Error al ingresar</div>';

                }

            }

            else{

                    $intentos = 0;

                    $datosController = array("usuarioActual"=>$usuarioActual, "actualizarIntentos"=>$intentos);

                    $respuestaActualizarIntentos = IngresoModels::intentosModel($datosController, "usuarios");

                    echo '<div class="alert alert-danger">Ha fallado 3 veces, demuestre que no es un robot</div>';

            }

        }

    }
}

}
    
asked by ssbizkit 20.08.2018 в 15:59
source

1 answer

0

Both errors indicate that you have already started to write an answer when you try to modify the headers of the request. This occurs with SESSION_START() as well as HEADER() .

To verify this, you can tell php to quit before running SESSION_START() with EXIT

...

$respuestaActualizarIntentos = IngresoModels::intentosModel($datosController, "usuarios");

exit("Antes de este mensaje, no debería aparecer nada en el cuerpo de la respuesta. Si es así, no puedo utilizar session_start ni header en este punto.");

session_start();

$_SESSION["validar"] = true;

...
    
answered by 20.08.2018 / 16:59
source