Edit dashboard.php via Editor
This commit is contained in:
parent
5eac55563f
commit
27e631c514
@ -1,72 +1,25 @@
|
|||||||
<?php
|
<?php
|
||||||
session_start();
|
session_start();
|
||||||
|
header("Content-Type: application/json");
|
||||||
|
|
||||||
if (!isset($_SESSION['user_id'])) {
|
require "db/config.php";
|
||||||
header('Location: login.php');
|
|
||||||
|
$userId = $_SESSION['user_id'] ?? null;
|
||||||
|
|
||||||
|
if (!$userId) {
|
||||||
|
http_response_code(401);
|
||||||
|
echo json_encode(["error" => "unauthorized"]);
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$stmt = $pdo->prepare("
|
||||||
|
SELECT id, title, status, created_at, updated_at, final_video_url
|
||||||
|
FROM projects
|
||||||
|
WHERE user_id = ?
|
||||||
|
ORDER BY created_at DESC
|
||||||
|
");
|
||||||
|
$stmt->execute([$userId]);
|
||||||
|
|
||||||
|
echo json_encode($stmt->fetchAll());
|
||||||
|
exit;
|
||||||
?>
|
?>
|
||||||
<!DOCTYPE html>
|
|
||||||
<html lang="en">
|
|
||||||
<head>
|
|
||||||
<meta charset="UTF-8">
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
||||||
<title>Dashboard - AI Cinema Engine</title>
|
|
||||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<nav class="navbar navbar-expand-lg navbar-light bg-light">
|
|
||||||
<div class="container-fluid">
|
|
||||||
<a class="navbar-brand" href="#">AI Cinema Engine</a>
|
|
||||||
<div class="collapse navbar-collapse" id="navbarNav">
|
|
||||||
<ul class="navbar-nav ms-auto">
|
|
||||||
<li class="nav-item">
|
|
||||||
<a class="nav-link" href="logout.php">Logout</a>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</nav>
|
|
||||||
<div class="container mt-5">
|
|
||||||
<h1>Welcome to your Dashboard</h1>
|
|
||||||
<p>Hello, <?php echo htmlspecialchars($_SESSION['user_email']); ?>!</p>
|
|
||||||
<p>This is your protected dashboard. You can manage your projects and scenes from here.</p>
|
|
||||||
|
|
||||||
<div class="d-flex justify-content-between align-items-center mt-5 mb-3">
|
|
||||||
<h2>My Projects</h2>
|
|
||||||
<a href="create_project.php" class="btn btn-primary">Create New Project</a>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<?php
|
|
||||||
require_once 'db/config.php';
|
|
||||||
$pdo = db();
|
|
||||||
$stmt = $pdo->prepare("SELECT * FROM projects WHERE user_id = ? ORDER BY created_at DESC");
|
|
||||||
$stmt->execute([$_SESSION['user_id']]);
|
|
||||||
$projects = $stmt->fetchAll();
|
|
||||||
|
|
||||||
if (count($projects) > 0):
|
|
||||||
?>
|
|
||||||
<div class="list-group">
|
|
||||||
<?php foreach ($projects as $project): ?>
|
|
||||||
<a href="view_project.php?id=<?php echo $project['id']; ?>" class="list-group-item list-group-item-action">
|
|
||||||
<div class="d-flex w-100 justify-content-between">
|
|
||||||
<h5 class="mb-1"><?php echo htmlspecialchars($project['title']); ?></h5>
|
|
||||||
<small>Status: <?php echo htmlspecialchars($project['status']); ?></small>
|
|
||||||
</div>
|
|
||||||
<p class="mb-1">Last updated: <?php echo $project['updated_at']; ?></p>
|
|
||||||
</a>
|
|
||||||
<?php endforeach; ?>
|
|
||||||
</div>
|
|
||||||
<?php else: ?>
|
|
||||||
<div class="text-center p-5 border rounded">
|
|
||||||
<h4>No projects yet.</h4>
|
|
||||||
<p>Get started by creating your first project.</p>
|
|
||||||
</div>
|
|
||||||
<?php endif; ?>
|
|
||||||
|
|
||||||
|
|
||||||
</div>
|
|
||||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user