I'm receiving the following error message when I submit user data from my form to the db
Fatal error: Uncaught Error: Call to undefined function insertUserDetails() in /Applications/XAMPP/xamppfiles/htdocs/Spotifyclone/includes/accounts/Account.php:175 Stack trace: #0 /Applications/XAMPP/xamppfiles/htdocs/Spotifyclone/includes/handlers/register-handlers.php(49): Account->register('Bartthewonder', 'Bartholemewjohn...', 'Simpson', 'Bart.simpson@gm...', 'Bart.simpson@gm...', 'password', 'password') #1 /Applications/XAMPP/xamppfiles/htdocs/spotifyclone/register.php(21): include('/Applications/X...') #2 {main} thrown in /Applications/XAMPP/xamppfiles/htdocs/Spotifyclone/includes/accounts/Account.php on line 175
insertUserDetails is the function in question .
Line 175 from my account.php file is the following:
return insertUserDetails($un, $fn, $ln, $em, $pw);
Below is the full code pasted
<?php
 class Account {
        private $con;
        private $errorArray;
        public function __construct($con) {
            $this->con = $con;
            $this->errorArray = array();
        }
        public function register($un, $fn, $ln, $em, $em2, $pw, $pw2) {
            $this->validateUsername($un);
            $this->validateFirstName($fn);
            $this->validateLastName($ln);
            $this->validateEmails($em, $em2);
            $this->validatePasswords($pw, $pw2);
            if(empty($this->errorArray) == true) {
                //Insert into db
                return insertUserDetails($un, $fn, $ln, $em, $pw);
            }
            else {
                return false;
            }
        }
        public function getError($error) {
            if(!in_array($error, $this->errorArray)) {
                $error = "";
            }
            return "<span class='errorMessage'>$error</span>";
        }
        private function insertUserDetails($un, $fn, $ln, $em, $pw) {
            $encryptedPw = md5($pw);
            $profilePic = "assets/images/profile-pics/head_emerald.png";
            $date = date("Y-m-d");
            $result = mysqli_query($this->con, "INSERT INTO users VALUES ('', '$un', '$fn', '$ln', '$em', '$encryptedPw', '$date', '$profilePic')");
            return $result;
        }
        private function validateUsername($un) {
            if(strlen($un) > 25 || strlen($un) < 5) {
                array_push($this->errorArray, Constants::$usernameCharacters);
                return;
            }
            //TODO: check if username exists
        }
        private function validateFirstName($fn) {
            if(strlen($fn) > 25 || strlen($fn) < 2) {
                array_push($this->errorArray, Constants::$firstNameCharacters);
                return;
            }
        }
        private function validateLastName($ln) {
            if(strlen($ln) > 25 || strlen($ln) < 2) {
                array_push($this->errorArray, Constants::$lastNameCharacters);
                return;
            }
        }
        private function validateEmails($em, $em2) {
            if($em != $em2) {
                array_push($this->errorArray, Constants::$emailsDoNotMatch);
                return;
            }
            if(!filter_var($em, FILTER_VALIDATE_EMAIL)) {
                array_push($this->errorArray, Constants::$emailInvalid);
                return;
            }
            //TODO: Check that username hasn't already been used
        }
        private function validatePasswords($pw, $pw2) {
            if($pw != $pw2) {
                array_push($this->errorArray, Constants::$passwordsDoNoMatch);
                return;
            }
            if(preg_match('/[^A-Za-z0-9]/', $pw)) {
                array_push($this->errorArray, Constants::$passwordNotAlphanumeric);
                return;
            }
            if(strlen($pw) > 30 || strlen($pw) < 5) {
                array_push($this->errorArray, Constants::$passwordCharacters);
                return;
            }
        }
    }
?>
 
     
    