I made sure that I was not sending any client sided data before hand and I turned on error reporting but nothing is happening.
It's a simple login script with a redirection on validation.
<?php
include_once "database-handler2.php";
require "password.php";
$UserName = $_POST["name"];
$Password = $_POST["pass"];
if(isset($UserName))
{
$query = "SELECT Password FROM users WHERE Username='$UserName'";
$hashed_password = mysqli_query($connection, $query);
while ($row = mysqli_fetch_row($hashed_password))
{
$res = $row[0];
}
if(password_verify($Password, $res)) {
// Show Errors
error_reporting(E_ALL);
ini_set('display_errors','On');
// Redirect
header('Location:http://example.com/ex/index.php', true);
die('redirect');
}
}
I have made sure that the other included php's don't have an extra whitespace or anything else. Using AJAX the success function does nothing, and if I turn on alert() or debug.log() the success message of the PHP's response (which there shouldn't be one) then I get a print out of the page I'm trying to redirect to's HTML without any error or other information under or above it.
Javascript code:
$('#submitButton').click(function()
{
var userName = document.getElementById("user").value;
var pass = document.getElementById("pass").value;
$.ajax({
url: '/handlers/login-handler.php',
type:'POST',
data:
{
name: userName,
pass: pass
},
success: function(msg)
{
alert(msg);
}
});
});
Please note that if I take the alert(msg); out than if I click the button nothing happens.
