My script is returning the 'error please contact support' output, and I honestly can't find the issue wrong with it so i'm hoping a new set of eyes will be able to spot this. I'm sure it's just a tiny idiotic mistake. Thanks.
<?php
session_start();
$con = mysqli_connect('localhost', 'root', '', 'test');
if (isset($_SESSION['user']) != "") {
header("Location: index.php");
}
if (isset($_POST['btn-signup'])) {
$escusername = mysqli_real_escape_string($con, $_POST['username']);
$escemail = mysqli_real_escape_string($con, $_POST['email']);
$hpassword = hash('sha512', $_POST['password']);
$query = "INSERT INTO `users` (username, email, password) VALUES('$escusername', '$escemail', '$hpassword')";
$result = mysqli_query($query);
if ($result) {
?>
<script>alert('your account has now been registered.');</script>
<?php
} else {
?>
<script>alert('error please contact support.');</script>
<?php
}
}
?>