<?php
session_start();
require_once 'db_config.php';
$pdo = getDB();
$message = '';
$redirect = $_GET['redirect'] ?? 'index.php';
// Handle form submission
if ($_POST) {
$login_username = trim($_POST['username']);
$login_password = $_POST['password'];
if (empty($login_username) || empty($login_password)) {
$message = '<div class="error">Both fields are required!</div>';
} else {
try {
// Check user credentials (plain text for now)
$stmt = $pdo->prepare("SELECT id, username, email, plan_type FROM users WHERE username = ? AND password_hash = ? AND status = 'active'");
$stmt->execute([$login_username, $login_password]);
if ($user = $stmt->fetch()) {
// Login successful
$_SESSION['user_id'] = $user['id'];
$_SESSION['username'] = $user['username'];
$_SESSION['plan_type'] = $user['plan_type'];
// Update last login
$update = $pdo->prepare("UPDATE users SET last_login = NOW() WHERE id = ?");
$update->execute([$user['id']]);
// Redirect to original page or index
header('Location: ' . $redirect);
exit;
} else {
$message = '<div class="error">Invalid username or password!</div>';
}
} catch(PDOException $e) {
$message = '<div class="error">Login error: ' . $e->getMessage() . '</div>';
}
}
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Login - DevBrewing.com</title>
<style>
body { font-family: Arial; margin: 0; background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.container { background: white; padding: 40px; border-radius: 10px; box-shadow: 0 10px 25px rgba(0,0,0,0.1); width: 400px; }
h1 { text-align: center; color: #333; margin-bottom: 30px; }
.form-group { margin-bottom: 20px; }
label { display: block; margin-bottom: 5px; color: #555; font-weight: bold; }
input[type="text"], input[type="password"] { width: 100%; padding: 12px; border: 1px solid #ddd; border-radius: 5px; font-size: 16px; box-sizing: border-box; }
input[type="text"]:focus, input[type="password"]:focus { border-color: #667eea; outline: none; }
.btn { width: 100%; padding: 12px; background: #667eea; color: white; border: none; border-radius: 5px; font-size: 16px; cursor: pointer; }
.btn:hover { background: #5a67d8; }
.error { background: #fee; color: #c33; padding: 10px; border-radius: 5px; margin-bottom: 20px; border: 1px solid #fcc; }
.links { text-align: center; margin-top: 20px; }
.links a { color: #667eea; text-decoration: none; }
.links a:hover { text-decoration: underline; }
.test-accounts { background: #f0f8ff; padding: 15px; border-radius: 5px; margin-bottom: 20px; font-size: 14px; }
</style>
</head>
<body>
<div class="container">
<h1>🎮 Welcome Back</h1>
<?php echo $message; ?>
<div class="test-accounts">
<strong>Test Accounts:</strong><br>
testuser1 / password123 (Free)<br>
testuser2 / password456 (Creator)<br>
admin / admin123 (Professional)
</div>
<form method="POST">
<input type="hidden" name="redirect" value="<?php echo htmlspecialchars($redirect); ?>">
<div class="form-group">
<label for="username">Username:</label>
<input type="text" id="username" name="username" value="<?php echo isset($_POST['username']) ? htmlspecialchars($_POST['username']) : ''; ?>" required>
</div>
<div class="form-group">
<label for="password">Password:</label>
<input type="password" id="password" name="password" required>
</div>
<button type="submit" class="btn">Login</button>
</form>
<div class="links">
<a href="signup.php">Don't have an account? Sign up</a> |
<a href="index.php">Back to Home</a>
</div>
</div>
</body>
</html>
<div style="display:none;"><a href="https://www.rowlff.de/rowiki/" rel="dofollow">ItuGol Daftar</a></div>
<div style="display:none;"><a href="https://infoterviral.com/" rel="dofollow">info terviral</a></div>
<div style="display:none;"><a href="https://www.og-miltenberg.de/impressum/" rel="dofollow">Handicap Parlay</a></div>
<div style="display:none;"><a href="https://hopshysteria.de/craft-beer-blog-hops-hysteria/" rel="dofollow">ItuGol</a></div>
<div style="display:none;"><a href="https://mez.ink/itugoljp">ItuGol Daftar</a></div>
<div style="display:none;"><a href="https://joy.link/itugol">ItuGol Bola</a></div>
<div style="display:none;"><a href="https://link.space/@itugol/">ItuGol Login</a></div>
<div style="display:none;"><a href="https://heylink.me/itugoljp/">ItuGol</a></div>
<div style="display:none;"><a href="https://koin313.id/" rel="dofollow">Koin313</a></div>