500 Internal Server Error

0


I am new and I have an error in the platform that I am programming with php, this error appears to me now, I already put the permissions to the folders and the files, in my localhost it works perfect the error is in the server what is with IIS8
-
 POST http: //*******/Controller/Login/Login.php 500 (Internal Server Error) jquery-3.3.1.js: 9600. I know that the ajax function is working well because throws me the error message I put on it

so you see the error in the chrome console
is a form that sends 2 fields the post,
here my code

so you see the error in the chrome network ajax function

//---------------- FUNCION AJAX ------------------//
    function fajax(url, parametros, metodo) {
        $.ajax({
            url: url,
            data: parametros,
            type: 'post',
            cache: false,
            beforeSend: function () {
                $(document).ajaxStop();
                $(document).ajaxStart();
            },
            dataType: 'html',
            contentType: 'application/x-www-form-urlencoded; charset=utf-8;',
            timeout: 8000,
            success: function (datos) {
                metodo(datos);
            },
            error: function (xhr, status) {
                alert("Por favor, valida tu conexión !")
            }
        })
    }

login function

//-------------- LOGIN ------------------------//
    var url = "index.php";
    var parametros = "acceso=true";
    var metodo = function (datos) {
        $("#login").validate({
            rules: {
                correo: {required: true, email: true},
                contrasena: {required: true, minlength: 3}
            },
            messages: {
                correo: {
                    required: '<font color="red"> Debe colocar elcorreo</font>',
                    email: '<font color="red">Debe colocar su correo electronico</font>',
                },
                contrasena: {
                    required: "Debe colocar una contraseña",
                    minlength: '<font color="red">Debe colocar minimo 3 cracteres</font>',

                },
            },
            submitHandler: function () {
                var url = "Controller/Login/Login.php";
                var parametros = $("#login").serialize();
                var metodo = function (datos) {
                  
                    datos = $.parseJSON(datos);
                    if (datos.success == "ok") {
                        if (datos["result"][0]["lenguaje"] == 'SPANISH') {
                            // alerPos("Perfecto !", "<b>" + datos["result"][0]["NombreColabora"] + " " + datos["result"][0]["ApellidoColabora"] + " Bienvenido</b>");
                            setTimeout("location.href='Pages/Main.php'", 1000);
                        } else {
                            // alerPos("Excellent !", "<b>" + datos["result"][0]["NombreColabora"] + " " + datos["result"][0]["ApellidoColabora"] + " Welcome</b>");
                            setTimeout("location.href='EN/Pages/Main.php'", 1000);
                        }
                    } else {
                        alerNeg("Error ", "<br>error, it is not possible to enter.<br>");
                    }
                };
                fajax(url, parametros, metodo);
            }
        });
    };
    fajax(url, parametros, metodo);

Controller

<?php
if ($_POST) {
    ob_start();
    session_start();
    //session_name("seExtra");
    require '../../CLASS/BD/datos.php';
    require '../../CLASS/BD/MySQLi.php';
    require '../../CLASS/VO/ColaboradorVO.php';
    require '../../CLASS/DAO/loginDAO.php';
    ini_set('display_errors', 1);
    $ColaboraVO = new LoginDAO();
    $data = json_encode($_POST);
    $json = json_decode($data);
    $ColaboraVO->Login($json);
} else { header("location:../.././");} 




I hope you can help me soon, I appreciate your help beforehand

    
asked by Carlos Blanco 04.12.2018 в 17:02
source

2 answers

1

500 errors are from the server. Which means that within your php file any of your functions is not doing its duty so it thunders at that moment.

This section causes me noise.

header("location:../.././");

Since if I remember correctly, this does the redirection to the folder, however if the folder does not contain an index.php file then you are not referencing anything. So you could start there to see if the redirect is well done.

Also if we translate your redirection it would be "Upload a folder, upload another folder, in this folder this ..." sure it would not be "location: ../../ index.php" or "location: .. /../../ index.php "

    
answered by 04.12.2018 в 17:11
0


I was able to solve the problem, I published the solution.
it turns out that it managed the connection to the BDD separating the data in one file and the connection in another, the solution was, placing the direct data in the connection file and removing all files from the import of the connection data file, this I pass a server with windows server 2012 R2 and IIS 8.
 I publish the codes to make the solution more understandable.

Database data file for the BDD

<?php
class Datos {
    private $hostname = 'UBICACION DE LA BDD';
    private $usuario = 'USUARIO DE LA BDD'
    private $clave = 'CLAVE DE CONEXION';
    private $db = 'NOMBRE DE LA BDD';
    
    public function Datos() {
        
    }
    public function get_hostname() {
        return $this->hostname;
    }
    public function get_usuario() {
        return $this->usuario;
    }
    public function get_clave() {
        return $this->clave;
    }
    public function get_DB() {
        return $this->db;
    }
}


Controller

<?php
if ($_POST) {
 //   ob_start();
    session_start();
    //session_name("seExtra");
 //   include '../CLASS/BD/datos.php';
    require '../../CLASS/BD/MySQLi.php';
    require '../../CLASS/VO/ColaboradorVO.php';
    require '../../CLASS/DAO/loginDAO.php';
    ini_set('display_errors', 0);
    $ColaboraVO = new LoginDAO();
    $data = json_encode($_POST);
    $json = json_decode($data);
    $ColaboraVO->Login($json);
	} else { header("location:../.././");} 
?>
    
answered by 05.12.2018 в 19:02