<?php
class NewUserForm extends DbConn
{
    public function createUser($usr, $uid, $email, $pw, $tel1, $tel2, $fullname)
    {
        try {

            $db = new DbConn;
            $tbl_members = $db->tbl_members;
            // prepare sql and bind parameters
            $stmt = $db->conn->prepare("INSERT INTO ".$tbl_members." (id, username, password, email, tel1, tel2, fullname)
            VALUES (:id, :username, :password, :email, :tel1, :tel2, :fullname)");
            $stmt->bindParam(':id', $uid);
            $stmt->bindParam(':username', $usr);
            $stmt->bindParam(':email', $email);
            $stmt->bindParam(':password', $pw);
            $stmt->bindParam(':tel1', $tel1);
            $stmt->bindParam(':tel2', $tel2);
            $stmt->bindParam(':fullname', $fullname);
            $stmt->execute();

            $err = '';

        } catch (PDOException $e) {

            $err = "Error: " . $e->getMessage();

        }
        //Determines returned value ('true' or error code)
        if ($err == '') {

            $success = 'true';

        } else {

            $success = $err;

        };

        return $success;

    }
}
