webserver/htdocs/singlefilelogin.php
// create named user if does not exist from ini data sor just update the password
create named user if does not exist from ini data sor just update the password
create named user if does not exist from ini data sor just update the password
private function makeOrUpdateUser($user)
    {   if (!isset($this->ini[$user."_password"]))
            return;
        $sql = 'SELECT user_name, user_email, user_password_hash
            FROM users
            WHERE user_name = :user_name
            LIMIT 1';
        $query = $this->db_connection->prepare($sql);
        $query->bindValue(':user_name', $user);
        $query->execute();
        $result_row = $query->fetchObject();
        if (!$result_row) {
            $sql = 'INSERT INTO users (user_name, user_password_hash, user_email)
                VALUES(:user_name, :user_password_hash, :user_email)';
            $query = $this->db_connection->prepare($sql);
            $query->bindValue(':user_name', $user);
            $query->bindValue(':user_password_hash', password_hash($this->ini[$user."_password"], PASSWORD_DEFAULT));
            $query->bindValue(':user_email', $this->ini[$user."_email"] ?? '');
            $query->execute();
        }
        else if (!password_verify($this->ini[$user."_password"], $result_row->user_password_hash)) {
            $sql = 'UPDATE users SET user_password_hash=:user_password_hash, user_email=:user_email 
                    WHERE user_name=:user_name';
            $query = $this->db_connection->prepare($sql);
            $query->bindValue(':user_name', $user);
            $query->bindValue(':user_email', $this->ini[$user."_email"] ?? '');
            $query->bindValue(':user_password_hash', password_hash($this->ini[$user."_password"], PASSWORD_DEFAULT));
            $query->execute();
        }
    }
private function makeOrUpdateUser ( $ user ) { if ( ! isset ( $ this -> ini [ $ user . " _password " ] ) ) return ; $ sql = 'SELECT user_name, user_email, user_password_hash
            FROM users
            WHERE user_name = :user_name
            LIMIT 1' ; $ query = $ this -> db_connection -> prepare ( $ sql ) ; $ query -> bindValue ( ':user_name' , $ user ) ; $ query -> execute ( ) ; $ result_row = $ query -> fetchObject ( ) ; if ( ! $ result_row ) { $ sql = 'INSERT INTO users (user_name, user_password_hash, user_email)
                VALUES(:user_name, :user_password_hash, :user_email)' ; $ query = $ this -> db_connection -> prepare ( $ sql ) ; $ query -> bindValue ( ':user_name' , $ user ) ; $ query -> bindValue ( ':user_password_hash' , password_hash ( $ this -> ini [ $ user . " _password " ] , PASSWORD_DEFAULT ) ) ; $ query -> bindValue ( ':user_email' , $ this -> ini [ $ user . " _email " ] ?? '' ) ; $ query -> execute ( ) ; } else if ( ! password_verify ( $ this -> ini [ $ user . " _password " ] , $ result_row -> user_password_hash ) ) { $ sql = 'UPDATE users SET user_password_hash=:user_password_hash, user_email=:user_email 
                    WHERE user_name=:user_name' ; $ query = $ this -> db_connection -> prepare ( $ sql ) ; $ query -> bindValue ( ':user_name' , $ user ) ; $ query -> bindValue ( ':user_email' , $ this -> ini [ $ user . " _email " ] ?? '' ) ; $ query -> bindValue ( ':user_password_hash' , password_hash ( $ this -> ini [ $ user . " _password " ] , PASSWORD_DEFAULT ) ) ; $ query -> execute ( ) ; } }
create named user if does not exist from ini data sor just update the password
create named user if does not exist from ini data sor just update the password
// update named user password from ini data when changed