Hey so I've followed a tutorial on how to create a functional registration system with php and all the code seems to work just fine, however the data I input in my registration form doesn't show up in my database even though the script gives me the output that I have successfully registered. Does anyone know a solution to this?
<?php
// Connect to the db
$DATABASE_HOST = 'localhost';
$DATABSE_USER = 'root';
$DATABSE_PASS = '';
$DATABSE_NAME = 'phplogin';
// Try to connect
$con = mysqli_connect($DATABASE_HOST, $DATABSE_USER, $DATABSE_PASS, $DATABSE_NAME);
if(mysqli_connect_errno()) {
    //If there is an error stop the script and display the error
    exit('Failed to connect to MySQL: '. mysqli_connect_error());
}
//check if the data already exists
if (!isset($_POST['username'], $_POST['password'], $_POST['email'])) {
    //Could not get the data that should have been sent
    exit('Please register first');
}
//Submitted registration values are not empty
if (empty($_POST['username']) || empty($_POST['password']) || empty($_POST['email'])) {
    //if empty exit the script
    exit('Please complete the register form');
}
//check if the username has been used already
if ($stmt = $con->prepare('SELECT id, password FROM accounts WHERE username = ?')) {
    //encrypt password
    $stmt->bind_param('s', $_POST['username']);
    $stmt->execute();
    $stmt->store_result();
//store the results to be able to check the db
if ($stmt->num_rows > 0) {
    //username already exists
    echo 'Username already used';
} else {
    //Insert new account
    if ($stmt = $con->prepare('INSERT INTO accounts (username, password, email) VALUES (?, ?, ?)')) {
        //hash the password and use password_verify
        $password = password_hash($_POST['password'], PASSWORD_DEFAULT);
        $stmt->bind_param('sss', $_POST['username'], $password, $POST['email']);
        $stmt->execute();
        echo 'You have succesfully registered, you can now login';
    }}
    $stmt->close();
} else {
    //Something wrong with the sql statement
    echo 'Could not prepare Statement!';
}
$con->close();
?>
 
     
    