battles/user_anketa.php

42 lines
1.3 KiB
PHP

<?php
use Battles\Template;
use Battles\User;
require_once 'functions.php';
if (isset($_POST['name'])) {
User::getInstance()->profile()->setRealname($_POST['name']);
}
if (isset($_POST['hobbie'])) {
User::getInstance()->profile()->setInfo($_POST['hobbie']);
}
if (isset($_POST['oldpsw']) && isset($_POST['newpsw'])) {
User::getInstance()->profile()->changePassword($_POST['oldpsw'], $_POST['newpsw']);
}
if (!empty($_POST)) {
echo User::getInstance()->profile()->save();
}
Template::header('Анкета');
?>
<a href="main.php">← на главную</a>
<h1>Анкета персонажа <?= User::getInstance()->getLogin() ?></h1>
<form method="post">
<label>
<input name="name" placeholder="Реальное имя" value="<?= User::getInstance()->profile()->getRealname() ?>">
Реальное имя
</label><br>
<label>
<textarea name="hobbie" placeholder="Хобби"><?= User::getInstance()->profile()->getInfo() ?></textarea>
</label><br>
<input name="submit" type="submit">
</form>
<h1>Безопасность</h1>
<form method="post">
<label><input placeholder="Старый пароль" name="oldpsw"></label>
<label><input placeholder="Новый пароль" name="newpsw"></label>
<input type="submit">
</form>