上传文件至 /
This commit is contained in:
102
login.php
Normal file
102
login.php
Normal file
@@ -0,0 +1,102 @@
|
||||
<?php
|
||||
require_once 'config.php';
|
||||
|
||||
if (isset($_SESSION['user_id'])) {
|
||||
header('Location: dashboard.php');
|
||||
exit;
|
||||
}
|
||||
|
||||
$error = '';
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
$email = trim($_POST['email']);
|
||||
$password = $_POST['password'];
|
||||
|
||||
if (empty($email) || empty($password)) {
|
||||
$error = t('fill_all_fields');
|
||||
} else {
|
||||
$stmt = $pdo->prepare("SELECT * FROM users WHERE email = ?");
|
||||
$stmt->execute([$email]);
|
||||
$user = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
|
||||
if ($user && password_verify($password, $user['password'])) {
|
||||
if (!$user['is_verified']) {
|
||||
$error = t('verify_email_first');
|
||||
} else {
|
||||
$_SESSION['user_id'] = $user['id'];
|
||||
$_SESSION['username'] = $user['username'];
|
||||
$_SESSION['email'] = $user['email'];
|
||||
|
||||
header('Location: dashboard.php');
|
||||
exit;
|
||||
}
|
||||
} else {
|
||||
$error = t('invalid_credentials');
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="<?php echo $lang; ?>" data-theme="<?php echo $currentUserSettings['dark_mode'] ? 'dark' : 'light'; ?>">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title><?php echo t('login'); ?> - <?php echo SITE_NAME; ?></title>
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css">
|
||||
<link rel="stylesheet" href="css/style.css">
|
||||
</head>
|
||||
<body>
|
||||
<?php include 'components/navbar.php'; ?>
|
||||
|
||||
<div class="container">
|
||||
<div class="auth-container">
|
||||
<div class="auth-card card">
|
||||
<h2><i class="fas fa-sign-in-alt"></i> <?php echo t('user_login'); ?></h2>
|
||||
|
||||
<?php if($error): ?>
|
||||
<div class="alert alert-error">
|
||||
<i class="fas fa-exclamation-triangle"></i> <?php echo $error; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<form method="POST" action="">
|
||||
<div class="form-group">
|
||||
<label for="email">
|
||||
<i class="fas fa-envelope"></i> <?php echo t('email'); ?>
|
||||
</label>
|
||||
<input type="email" id="email" name="email" required
|
||||
value="<?php echo isset($_POST['email']) ? htmlspecialchars($_POST['email']) : ''; ?>"
|
||||
placeholder="<?php echo t('enter_email'); ?>">
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="password">
|
||||
<i class="fas fa-lock"></i> <?php echo t('password'); ?>
|
||||
</label>
|
||||
<input type="password" id="password" name="password" required
|
||||
placeholder="<?php echo t('enter_password'); ?>">
|
||||
</div>
|
||||
|
||||
<button type="submit" class="btn btn-primary btn-full">
|
||||
<i class="fas fa-sign-in-alt"></i> <?php echo t('login'); ?>
|
||||
</button>
|
||||
</form>
|
||||
|
||||
<div class="auth-links">
|
||||
<p>
|
||||
<a href="forgot-password.php">
|
||||
<i class="fas fa-key"></i> <?php echo t('forgot_password'); ?>
|
||||
</a>
|
||||
</p>
|
||||
<p>
|
||||
<?php echo t('no_account'); ?>
|
||||
<a href="register.php">
|
||||
<i class="fas fa-user-plus"></i> <?php echo t('register_now'); ?>
|
||||
</a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user