} elseif (empty($password) || empty($pwdConfirm)) {
     header("HTTP/1.0 401 Invalid submitted data");
     echo '{"status":"fail", "message":"Password or confirm password fields cannot be empty."}';
 } elseif (empty($email)) {
     header("HTTP/1.0 401 Invalid submitted data");
     echo '{"status":"fail", "message":"Email field cannot be empty, or it is not a valid email address"}';
 } elseif ($password !== $pwdConfirm) {
     header("HTTP/1.0 401 Invalid submitted data");
     echo '{"status":"fail","message":"Passwords donot match."}';
 } elseif (strlen($password) < 7) {
     header("HTTP/1.0 401 Invalid submitted data");
     echo '{"status":"fail", "message":"Passwords should be at least 7 characters long."}';
 } elseif (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
     header("HTTP/1.0 401 Invalid submitted data");
     echo '{"status":"fail", "message":"Please input valid email address!"}';
 } elseif ($db->isConnected()) {
     // let's make sure user doesn't exists
     $pdo = $db->getConnection();
     $query = $pdo->prepare("SELECT user_name from users WHERE user_name = :username");
     $query->bindValue(':username', $username, PDO::PARAM_STR);
     $query->execute();
     $result = $query->fetchAll();
     if (count($result) > 0 || count($errors) > 0) {
         header("HTTP/1.0 401 Invalid submitted data");
         echo '{"status":"fail", "message":"Please make sure your password or username are valids"}';
         //json_encode($errors);
     } else {
         // check to see if we don't have errors
         try {
             $options = ['cost' => 12];
             $user_password_hash = password_hash($password, PASSWORD_BCRYPT, $options);