Hi I want to create a login form, but need some help with the code below because it doesn't seem working:

<?php
session_start();

if(isset($_POST['submit']))
{
if(isset($_POST['username'], $_POST['password']))
{
$con=mysqli_connect("localhost","root","","sgptt");
$username = mysqli_real_escape_string($con, $_POST['username']);
$password = hash('sha512', $_POST['password']);
$exists = mysqli_query($con, "SELECT COUNT(*) FROM useraccount WHERE Username = '{$username}' AND Password = '{$password}'") or die(mysqli_error($con));

if(mysqli_fetch_array($exists, MYSQL_NUM) === 1)
{
echo("Login Sucessfull") ;
}
else
{
echo("Login fail");

}
}
}
?>