public function enter() { $model = new Model_User(); if (empty($_POST['email'])) { $errors[] = 'Вы не ввели email!'; } if (empty($_POST['password'])) { $errors[] = 'Вы не ввели пароль!'; } if (!empty($_POST['email']) and !filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) { $errors[] = 'Введите валидный email!'; } if (!empty($_POST['password']) and strlen($_POST['password']) < 6) { $errors[] = 'Пароль должен содержать не менее 6 символов!'; } if (!empty($errors)) { $this->template->vars('errors', $errors); $this->template->view('login'); } if (empty($errors)) { $data = ['email' => $_POST['email'], 'password' => $_POST['password']]; $user = $model->user_enter($data); if ($user) { $model->redirect('/weather'); } else { $errors[] = 'Неверный email или пароль'; $this->template->vars('errors', $errors); $this->template->view('login'); } } }
<?php if (\App\Models\Model_User::is_auth()) { if (!empty($result)) { foreach ($result as $result_data) { echo '<h4>' . $result_data->results->channel->location->city . ', '; echo $result_data->results->channel->location->country . '</h4>'; echo $result_data->results->channel->item->description; } } } else { echo 'Только зарегестрированные пользователи могут видеть погоу'; }