- initial
This commit is contained in:
+45
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
require_once __DIR__.'/includes/boot.php';
|
||||
requireLogin();
|
||||
$pageTitle = 'Account Settings — Keyser WV';
|
||||
$u = qone("SELECT * FROM users WHERE id=?",[uid()]);
|
||||
$errors = [];
|
||||
if (isPost()) {
|
||||
csrfCheck();
|
||||
$em = ps('email'); $pw = ps('password'); $pw2 = ps('password2');
|
||||
if ($em && !filter_var($em,FILTER_VALIDATE_EMAIL)) $errors[] = 'Invalid email address.';
|
||||
if ($pw) {
|
||||
if (strlen($pw) < 6) $errors[] = 'Password must be at least 6 characters.';
|
||||
if ($pw !== $pw2) $errors[] = 'Passwords do not match.';
|
||||
}
|
||||
if (!$errors && $em && $em !== $u['email'] && qval("SELECT id FROM users WHERE email=? AND id!=?",[$em,uid()])) $errors[] = 'Email already in use.';
|
||||
if (!$errors) {
|
||||
if ($pw) qrun("UPDATE users SET email=?,password=? WHERE id=?",[$em?:null,password_hash($pw,PASSWORD_BCRYPT),uid()]);
|
||||
else qrun("UPDATE users SET email=? WHERE id=?",[$em?:null,uid()]);
|
||||
flash('Account updated successfully!','success'); go('/account.php');
|
||||
}
|
||||
$u['email'] = $em;
|
||||
}
|
||||
include __DIR__.'/includes/header.php';
|
||||
?>
|
||||
<div class="form-box" style="max-width:520px">
|
||||
<h1 class="form-title">Account Settings</h1>
|
||||
<p class="form-sub">Manage your Discover Keyser WV account</p>
|
||||
<div class="ibox" style="margin-bottom:1.5rem">
|
||||
<div class="ibox-title">ACCOUNT INFO</div>
|
||||
<div class="irow"><span class="irow-i">👤</span><span class="irow-v"><?=e($u['username'])?> <?=isAdmin()?'<span class="badge badge-gold">ADMIN</span>':''?></span></div>
|
||||
<div class="irow"><span class="irow-i">📅</span><span class="irow-v">Joined <?=fdate($u['created_at'])?></span></div>
|
||||
<?php if($u['last_login']): ?><div class="irow"><span class="irow-i">🕐</span><span class="irow-v">Last login: <?=ago($u['last_login'])?></span></div><?php endif; ?>
|
||||
</div>
|
||||
<?php if($errors): ?><div class="err-box"><?=implode('<br>',array_map('e',$errors))?></div><?php endif; ?>
|
||||
<form method="POST">
|
||||
<?=csrfField()?>
|
||||
<div class="fg"><label class="flabel">EMAIL ADDRESS</label><input type="email" name="email" class="finput" value="<?=e($u['email']??'')?>"></div>
|
||||
<hr class="divider" style="margin:1.25rem 0">
|
||||
<p style="font-family:'Oswald',sans-serif;font-size:.72rem;letter-spacing:.1em;color:var(--gold);margin-bottom:.85rem">CHANGE PASSWORD (leave blank to keep current)</p>
|
||||
<div class="fg"><label class="flabel">NEW PASSWORD</label><input type="password" name="password" class="finput" autocomplete="new-password"></div>
|
||||
<div class="fg"><label class="flabel">CONFIRM NEW PASSWORD</label><input type="password" name="password2" class="finput" autocomplete="new-password"></div>
|
||||
<button type="submit" class="btn btn-primary btn-block">Save Changes</button>
|
||||
</form>
|
||||
</div>
|
||||
<?php include __DIR__.'/includes/footer.php'; ?>
|
||||
Reference in New Issue
Block a user