Fatal error: Uncaught Error: Cannot use object of type User as array

This commit is contained in:
lopar 2020-08-30 03:59:29 +03:00
parent c6ec8e8084
commit 666376b4e6
2 changed files with 8 additions and 7 deletions

View File

@ -4,6 +4,7 @@ class User
{
public $id = 0;
public $login = '<em>Некто</em>';
public $pass;
public $email = '<em>неизвестно</em>';
public $realname;
public $borndate;

View File

@ -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) {
</head>
<body>
<a href="main.php"> на главную</a>
<h1>Анкета персонажа <?= $user['login'] ?></h1>
<h1>Анкета персонажа <?= $user->login ?></h1>
<form method="post" action="user_anketa.php">
<input name="name" placeholder="Реальное имя" value="<?= $user['realname']; ?>"><br>
<input name="name" placeholder="Реальное имя" value="<?= $user->realname ?>"><br>
<select name="color" id="color">
<option value="0" selected>Чёрный</option>
<option value="1">Синий</option>
<option value="2">Зелёный</option>
</select><label for="color"></label><br>
<textarea name="hobbie" placeholder="Хобби"><?= $user['info'] ?></textarea><br>
<textarea name="hobbie" placeholder="Хобби"><?= $user->info ?></textarea><br>
<input name="submit" type="submit">
</form>
<h1>Безопасность</h1>