При проверке полей формы пишет, что поля не заполнены. При смене условий проверки angular дает ответ, что все хорошо. Но данные не заполняются в БД

Код php контролера

public function updateUsers (){
  if(!$_SESSION['user']) {
    header("Location: /");
  }
  if(empty($_POST) && !empty($_POST['fullName']) && !empty($_POST['phone']) && !empty($_POST['country']) && !empty($_POST['region']) && !empty($_POST['city']) && !empty($_POST['institution']) ) {
    $pofileId = $_POST['id'];
    $fullName = ($_POST['fullName']);
    $phone = ($_POST['phone']);
    $country =  ($_POST['country']);
    $region = $_POST['region'];
    $city = $_POST['city'];
    $institution = $_POST['institution'];
    if ($this->model->updateUsers($pofileId, $fullName, $phone, $country, $region, $city, $institution)) {
      echo json_encode(array("success" => true, "text" => "Данные пользователя обновлены"));
    } else {
      echo json_encode(array("success" => false, "text" => "Ошибка сохранения"));
    }
  }
}

Код php модели

public function updateUsers ($id, $fullName, $phone, $country, $region, $city, $institution) {
    $sql = "UPDATE  users SET fullName = :fullName, phone =:phone, country = :country, region = :region, city = :city, institution = :institution WHERE id = :id";

    $stmt = $this->db->prepare($sql);
    $stmt->bindValue(":fullName",$fullName, PDO::PARAM_STR);
    $stmt->bindValue(":phone",$phone, PDO::PARAM_STR);
    $stmt->bindValue(":country",$country, PDO::PARAM_STR);
    $stmt->bindValue(":region",$region, PDO::PARAM_STR);
    $stmt->bindValue(":city", $city, PDO::PARAM_STR);
    $stmt->bindValue(":institution", $institution, PDO::PARAM_STR);
    $stmt->bindValue(":id", $id, PDO::PARAM_INT);
    $stmt->execute();
    return true;
}

Код формы

<form id="form-settings" class="form-settings" method="POST" data-ng-submit ="updateUsers()" >
  <div class="form-settings__field">
    <input type="" id ="userId" name="userId"  value="<?php echo $pageData['userInfo']['id']?>"
    <label class="form-settings__name">ФИО:</label>
    <input class="form-settings__input" type="text" name="fullName" id="fullName" value=""
    data-ng-model ="fullName"  
    placeholder="Ввидеть полностью ФИО" />
  </div>
  <div class="form-settings__field">
    <label class="form-settings__name">Телефон (номер):</label>
    <input class="form-settings__input" type="tel" name="phone" id="phone" value=""
    placeholder="Введите свой номер телефон" data-ng-model ="phone"   />
  </div>
  <div class="form-settings__field">
    <label class="form-settings__name">Страна:</label>
    <input class="form-settings__input" type="text" id="country" name="country"
    placeholder="Введите свою страну" data-ng-model ="country"/>
  </div>
  <div class="form-settings__field">
    <label class="form-settings__name">Область:</label>
    <input class="form-settings__input" type="text" id="region" name="region"
    placeholder="Введите свой область" data-ng-model ="region"/>
  </div>
  <div class="form-settings__field">
    <label class="form-settings__name">Город:</label>
    <input class="form-settings__input" type="text" id="city" name="city"
    placeholder="Введите свой город" data-ng-model ="city"/>
  </div>
  <div class="form-settings__field">
    <label class="form-settings__name">Образовательное учреждение:</label>
    <input class="form-settings__input" type="text" id="institution" name="institution"
    placeholder="Введите свой институт" data-ng-model ="institution"/>
  </div>
  <div class="form-settings__button button">
    <button type="submit" class="button__save" id="update" name="update" >Сохранить</button>
    <button class="button__cancel" type="reset"> Отмена</button>
  </div>
</form>

Код JS

profile.controller("profileController", function($scope, $http, $window){

$scope.updateUsers = function (){
    id = angular.element("#userId").val();

    $http({
        method: "POST",
        url: "http://diplom1/cabinet/profile/updateUsers",
        data: $.param({id: id, fullName: $scope.fullName, phone: $scope.phone, country: $scope.country, region: $scope.region, city: $scope.city, institution: $scope.institution}),
        headers: {"Content-Type": 'application/x-www-form-urlencoded'}
    }).then(function(result){
        // TODO
        console.log(result);
    })
}

Что выдает JS в консоли введите сюда описание изображения


Ответы (0 шт):