From 666376b4e65536c32570f1d39a43625596fc00c0 Mon Sep 17 00:00:00 2001 From: lopar Date: Sun, 30 Aug 2020 03:59:29 +0300 Subject: [PATCH] Fatal error: Uncaught Error: Cannot use object of type User as array --- classes/User.php | 1 + user_anketa.php | 14 +++++++------- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/classes/User.php b/classes/User.php index 2088b62..b82e2ec 100644 --- a/classes/User.php +++ b/classes/User.php @@ -4,6 +4,7 @@ class User { public $id = 0; public $login = 'Некто'; + public $pass; public $email = 'неизвестно'; public $realname; public $borndate; diff --git a/user_anketa.php b/user_anketa.php index c9852fc..bbcd427 100644 --- a/user_anketa.php +++ b/user_anketa.php @@ -46,13 +46,13 @@ if ($name || $color || $hobbie) { err('Максимальная длинна поля Хобби: ' . INFO_CHAR_LIMIT . ' символов!'); } else { $values = ['realname' => $name, 'color' => $color, 'info' => $hobbie]; - $db->query('UPDATE users SET ?As WHERE id = ?i', $values, $user['id']); + $db->query('UPDATE users SET ?As WHERE id = ?i', $values, $user->id); } } if ($oldpsw && $newpsw) { - if (password_verify($oldpsw, $user['pass'])) { - db::c()->query('UPDATE `users` SET `pass` = "?s" WHERE `id` = ?i', password_hash($newpsw, PASSWORD_DEFAULT), $user['id']); + if (password_verify($oldpsw, $user->pass)) { + db::c()->query('UPDATE `users` SET `pass` = "?s" WHERE `id` = ?i', password_hash($newpsw, PASSWORD_DEFAULT), $user->id); } else { err('Неверный текущий пароль!'); } @@ -67,15 +67,15 @@ if ($oldpsw && $newpsw) { ← на главную -

Анкета персонажа

+

Анкета персонажа login ?>

-
+

-
+

Безопасность

@@ -85,4 +85,4 @@ if ($oldpsw && $newpsw) { - + \ No newline at end of file