60 lines
2.6 KiB
PHP
60 lines
2.6 KiB
PHP
<?php
|
|
require_once __DIR__ . '/../includes/lang.php';
|
|
require_once __DIR__ . '/../db/config.php';
|
|
|
|
$error = '';
|
|
|
|
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|
$account = $_POST['account'] ?? '';
|
|
$password = $_POST['password'] ?? '';
|
|
|
|
if (empty($account) || empty($password)) {
|
|
$error = 'Please fill in all fields';
|
|
} else {
|
|
$stmt = db()->prepare("SELECT * FROM users WHERE username = ? OR email = ?");
|
|
$stmt->execute([$account, $account]);
|
|
$user = $stmt->fetch();
|
|
|
|
if ($user && password_verify($password, $user['password_hash'])) {
|
|
$_SESSION['user_id'] = $user['id'];
|
|
header('Location: /');
|
|
exit;
|
|
} else {
|
|
$error = 'Invalid account or password';
|
|
}
|
|
}
|
|
}
|
|
|
|
include __DIR__ . '/../includes/header.php';
|
|
?>
|
|
|
|
<div style="max-width: 400px; margin: 100px auto; padding: 40px; background: var(--surface); border-radius: 8px; border: 1px solid var(--border);">
|
|
<h2 style="margin-bottom: 24px; text-align: center;"><?= __('login') ?></h2>
|
|
|
|
<?php if ($error): ?>
|
|
<div style="background: rgba(239, 83, 80, 0.1); color: var(--danger); padding: 12px; border-radius: 4px; margin-bottom: 20px; font-size: 14px;">
|
|
<?= $error ?>
|
|
</div>
|
|
<?php endif; ?>
|
|
|
|
<form method="POST">
|
|
<div style="margin-bottom: 20px;">
|
|
<label style="display: block; margin-bottom: 8px; font-size: 14px; color: var(--text-muted);">Account / Email</label>
|
|
<input type="text" name="account" style="width: 100%; padding: 12px; background: var(--bg); border: 1px solid var(--border); border-radius: 4px; color: #fff; box-sizing: border-box;" required>
|
|
</div>
|
|
|
|
<div style="margin-bottom: 24px;">
|
|
<label style="display: block; margin-bottom: 8px; font-size: 14px; color: var(--text-muted);"><?= __('password') ?></label>
|
|
<input type="password" name="password" style="width: 100%; padding: 12px; background: var(--bg); border: 1px solid var(--border); border-radius: 4px; color: #fff; box-sizing: border-box;" required>
|
|
</div>
|
|
|
|
<button type="submit" style="width: 100%; padding: 14px; background: var(--primary); border: none; border-radius: 4px; color: #fff; font-weight: bold; cursor: pointer;"><?= __('login') ?></button>
|
|
</form>
|
|
|
|
<div style="margin-top: 24px; text-align: center; font-size: 14px; color: var(--text-muted);">
|
|
New to OKX? <a href="/auth/register.php" style="color: var(--primary); text-decoration: none;">Create an account</a>
|
|
</div>
|
|
</div>
|
|
|
|
<?php include __DIR__ . '/../includes/footer.php'; ?>
|