webserver/htdocs/singlefilelogin.php
/**
     * Creates a PDO database connection (in this case to a SQLite flat-file database)
     * @return bool Database creation success status, false by default
     */
Creates a PDO database connection (in this case to a SQLite flat-file database)
@return bool Database creation success status, false by default
Creates a PDO database connection ( in this case to a SQLite flat - file database ) @return bool Database creation success status false by default
private function createDatabaseConnection()
    {
        try {
            $this->db_connection = new PDO($this->db_type . ':' . $this->db_sqlite_path);
            $sql = 'CREATE TABLE IF NOT EXISTS `users` (
                `user_id` INTEGER PRIMARY KEY,
                `user_name` varchar(64),
                `user_password_hash` varchar(255),
                `user_email` varchar(64));
                CREATE UNIQUE INDEX `user_name_UNIQUE` ON `users` (`user_name` ASC);
                CREATE UNIQUE INDEX `user_email_UNIQUE` ON `users` (`user_email` ASC);
                ';
            $query = $this->db_connection->prepare($sql);
            $query->execute();
            $this->makeOrUpdateUser('admin');
            $this->makeOrUpdateUser('teacher');
            $this->makeOrUpdateUser('student');
            $this->makeOrUpdateUser('moodle');
            return true;
        } catch (PDOException $e) {
            $this->feedback = "PDO database connection problem: " . $e->getMessage();
        } catch (Exception $e) {
            $this->feedback = "General problem: " . $e->getMessage();
        }
        return false;
    }
private function createDatabaseConnection ( ) { try { $ this -> db_connection = new PDO ( $ this -> db_type . ':' . $ this -> db_sqlite_path ) ; $ sql = 'CREATE TABLE IF NOT EXISTS `users` (
                `user_id` INTEGER PRIMARY KEY,
                `user_name` varchar(64),
                `user_password_hash` varchar(255),
                `user_email` varchar(64));
                CREATE UNIQUE INDEX `user_name_UNIQUE` ON `users` (`user_name` ASC);
                CREATE UNIQUE INDEX `user_email_UNIQUE` ON `users` (`user_email` ASC);
                ' ; $ query = $ this -> db_connection -> prepare ( $ sql ) ; $ query -> execute ( ) ; $ this -> makeOrUpdateUser ( 'admin' ) ; $ this -> makeOrUpdateUser ( 'teacher' ) ; $ this -> makeOrUpdateUser ( 'student' ) ; $ this -> makeOrUpdateUser ( 'moodle' ) ; return true ; } catch ( PDOException $ e ) { $ this -> feedback = " PDO database connection problem:  " . $ e -> getMessage ( ) ; } catch ( Exception $ e ) { $ this -> feedback = " General problem:  " . $ e -> getMessage ( ) ; } return false ; }
Creates a PDO database connection (in this case to a SQLite flat-file database)
 @return bool Database creation success status, false by default
Creates a PDO database connection ( in this case to a SQLite flat - file database ) @return bool Database creation success status false by default
// mvh 20201021 // create user table if does not exist