CoolFace
Apppublic

NeuralNodeAI/Freelance_Elite

sourceHugging Faceupdated 7mo agoView on Hugging Face
0likes
index.php82 linesDownload Raw Back to root
1<?php2// index.php3require 'db.php';4 5// Add a new task6if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['add_task'])) {7    $task = htmlspecialchars($_POST['task_name']);8    $client = htmlspecialchars($_POST['client_name']);9    if (!empty($task) && !empty($client)) {10        $stmt = $pdo->prepare("INSERT INTO tasks (task_name, client_name) VALUES (?, ?)");11        $stmt->execute([$task, $client]);12        header("Location: index.php");13        exit;14    }15}16 17// Mark task as completed18if (isset($_GET['complete'])) {19    $stmt = $pdo->prepare("UPDATE tasks SET status = 'completed' WHERE id = ?");20    $stmt->execute([$_GET['complete']]);21    header("Location: index.php");22    exit;23}24 25// Delete a task26if (isset($_GET['delete'])) {27    $stmt = $pdo->prepare("DELETE FROM tasks WHERE id = ?");28    $stmt->execute([$_GET['delete']]);29    header("Location: index.php");30    exit;31}32 33// Fetch all tasks (Pending first, then by date)34$tasks = $pdo->query("SELECT * FROM tasks ORDER BY status ASC, created_at DESC")->fetchAll(PDO::FETCH_ASSOC);35?>36 37<!DOCTYPE html>38<html lang="en">39<head>40    <meta charset="UTF-8">41    <meta name="viewport" content="width=device-width, initial-scale=1.0">42    <title>SoloSpace | Freelancer Dashboard</title>43    <link rel="stylesheet" href="style.css">44</head>45<body>46    <div class="container">47        <header>48            <h1>โœจ SoloSpace</h1>49            <p>Manage your freelance projects with ease and style</p>50        </header>51 52        <section class="add-task-section">53            <form action="index.php" method="POST" class="task-form">54                <input type="text" name="task_name" placeholder="What's the next task?" required>55                <input type="text" name="client_name" placeholder="Client Name" required>56                <button type="submit" name="add_task">Add Task</button>57            </form>58        </section>59 60        <main class="task-grid">61            <?php foreach ($tasks as $task): ?>62            <div class="task-card <?php echo $task['status']; ?>">63                <div class="card-content">64                    <h3><?php echo $task['task_name']; ?></h3>65                    <span class="client-badge">๐Ÿ‘ค <?php echo $task['client_name']; ?></span>66                </div>67                <div class="card-actions">68                    <?php if ($task['status'] === 'pending'): ?>69                        <a href="?complete=<?php echo $task['id']; ?>" class="btn complete">Complete</a>70                    <?php endif; ?>71                    <a href="?delete=<?php echo $task['id']; ?>" class="btn delete" onclick="return confirm('Are you sure you want to delete this?')">Delete</a>72                </div>73            </div>74            <?php endforeach; ?>75        </main>76        77        <?php if(empty($tasks)): ?>78            <p class="empty-msg">Your workspace is clear. Start by adding a new task! ๐Ÿš€</p>79        <?php endif; ?>80    </div>81</body>82</html>