28 lines
617 B
PHP
28 lines
617 B
PHP
<?php
|
|
session_start();
|
|
|
|
require_once 'db/config.php';
|
|
|
|
// Check if user is logged in
|
|
if (!isset($_SESSION['user_id'])) {
|
|
header("Location: register.php");
|
|
exit();
|
|
}
|
|
|
|
$userId = $_SESSION['user_id'];
|
|
|
|
try {
|
|
$pdo = db();
|
|
$stmt = $pdo->prepare("UPDATE users SET gameLevel = 1 WHERE id = :id");
|
|
$stmt->bindParam(':id', $userId, PDO::PARAM_INT);
|
|
$stmt->execute();
|
|
|
|
// Redirect to a success page
|
|
header("Location: level1_complete.php");
|
|
exit();
|
|
|
|
} catch (PDOException $e) {
|
|
// In a real app, log this error instead of displaying it
|
|
die("Database error: " . $e->getMessage());
|
|
}
|
|
?>
|