Add profile page
This commit is contained in:
parent
55e1d158d6
commit
d0b20f5736
3 changed files with 42 additions and 9 deletions
|
@ -1,14 +1,15 @@
|
|||
$(function() {
|
||||
$('.ui.calendar').calendar({
|
||||
type : 'date',
|
||||
firstDayOfWeek: 1,
|
||||
firstDayOfWeek : 1,
|
||||
startMode : 'year'
|
||||
});
|
||||
|
||||
$('.ui.form').form({
|
||||
fields: {
|
||||
'user-email': 'email',
|
||||
match: {
|
||||
'user-email' : 'email',
|
||||
'user-password' : ['minLength[8]', 'empty'],
|
||||
match : {
|
||||
identifier : 'user-password-repeat',
|
||||
depends : 'user-password',
|
||||
rules : [
|
||||
|
|
|
@ -124,7 +124,8 @@ switch ($step) {
|
|||
`password_reset_token` VARCHAR(128) NULL DEFAULT NULL,
|
||||
`password_reset_valid_until` DATETIME NOT NULL DEFAULT NOW(),
|
||||
`last_login` DATETIME NOT NULL DEFAULT NOW(),
|
||||
`power` INT NOT NULL DEFAULT 0
|
||||
`power` INT NOT NULL DEFAULT 0,
|
||||
`birthdate` DATE NULL DEFAULT NULL
|
||||
);');
|
||||
$database->query('CREATE INDEX `idx_password` ON `users` (`password`);');
|
||||
|
||||
|
|
|
@ -6,7 +6,32 @@
|
|||
* @author Jay Trees <github.jay@grandel.anonaddy.me>
|
||||
*/
|
||||
|
||||
use wishthis\Page;
|
||||
use wishthis\{Page, User};
|
||||
|
||||
if (isset($_POST['user-id'])) {
|
||||
$set = array();
|
||||
|
||||
if (!empty($_POST['user-email'])) {
|
||||
$set[] = '`email` = "' . $_POST['user-email'] . '"';
|
||||
}
|
||||
|
||||
if (!empty($_POST['user-password']) && !empty($_POST['user-password-repeat'])) {
|
||||
$set[] = '`password` = "' . User::generatePassword($_POST['user-password']) . '"';
|
||||
}
|
||||
|
||||
if (!empty($_POST['user-birthdate'])) {
|
||||
$set[] = '`birthdate` = "' . date('Y-m-d', strtotime($_POST['user-birthdate'])) . '"';
|
||||
}
|
||||
|
||||
$database
|
||||
->query('UPDATE `users`
|
||||
SET ' . implode(',', $set) . '
|
||||
WHERE `id` = ' . $_POST['user-id']);
|
||||
|
||||
session_destroy();
|
||||
header('Location: /?page=home');
|
||||
die();
|
||||
}
|
||||
|
||||
$page = new Page(__FILE__, __('Profile'));
|
||||
$page->header();
|
||||
|
@ -19,7 +44,9 @@ $page->navigation();
|
|||
<h1 class="ui header"><?= $page->title ?></h1>
|
||||
|
||||
<div class="ui segment">
|
||||
<form class="ui form">
|
||||
<form class="ui form" method="POST">
|
||||
<input type="hidden" name="user-id" value="<?= $user->id ?>" />
|
||||
|
||||
<div class="field">
|
||||
<label><?= __('Email') ?></label>
|
||||
|
||||
|
@ -46,7 +73,11 @@ $page->navigation();
|
|||
<div class="ui calendar">
|
||||
<div class="ui input left icon">
|
||||
<i class="calendar icon"></i>
|
||||
<input type="text" placeholder="<?= __('Pick a date') ?>" />
|
||||
<input type="text"
|
||||
name="user-birthdate"
|
||||
placeholder="<?= __('Pick a date') ?>"
|
||||
value="<?= $user->birthdate ?>"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
Loading…
Reference in a new issue