so I get internal server error 500 while trying to access the file with this code off. When I comment the line
$result = $conn->query("SELECT * FROM users WHERE username='$username'");
it's all okay then, but ofcourse I need this to make my code work. Can't find any mistakes in the code. Full code below.
<?php
include("assets/settings.php");
session_start();
$resp = array();
$username = $_POST["username"];
$password = $_POST["password"];
$resp['submitted_data'] = $_POST;
$login_status = 'invalid';
$result = $conn->query("SELECT * FROM users WHERE username='$username'");
if ($result->num_rows > 0) {
$row = mysqli_fetch_assoc($result);
if($row['password'] == md5($password)) {
$login_status = 'success';
$_SESSION["user"] = $row['id'];
} else $login_status = 'success';
}
$login_status = 'success';
$resp['login_status'] = $login_status;
if($login_status == 'success')
{
$resp['redirect_url'] = 'index.php';
}
echo json_encode($resp);
?>