fork download
  1. <?php
  2. if (!isset($_SESSION['username'])) {
  3. header('Location: index.php');
  4. exit();
  5. }
  6.  
  7. if ($_SERVER['REQUEST_METHOD'] === 'POST') {
  8. $title = trim($_POST['title']);
  9. $username = $_SESSION['username'];
  10.  
  11. if (!empty($title)) {
  12. require 'db.php';
  13. $stmt = $mysqli->prepare("INSERT INTO tasks (title, username, status) VALUES (?, ?, 'Pending')");
  14. $stmt->bind_param('ss', $title, $username);
  15. $stmt->execute();
  16. $stmt->close();
  17. $mysqli->close();
  18.  
  19. header('Location: todo.php');
  20. exit();
  21. }
  22. }
  23. ?>
  24.  
  25. <!DOCTYPE html>
  26. <html lang="en">
  27. <head>
  28. <meta charset="UTF-8" />
  29. <meta name="viewport" content="width=device-width, initial-scale=1" />
  30. <title>Add Task</title>
  31. <link rel="stylesheet" href="https://c...content-available-to-author-only...e.com/ajax/libs/font-awesome/5.15.4/css/all.min.css" />
  32. <style>
  33. body {
  34. font-family: Arial, sans-serif;
  35. background-color: #f4f4f4;
  36. display: flex;
  37. justify-content: center;
  38. align-items: center;
  39. height: 100vh;
  40. margin: 0;
  41. }
  42. .container {
  43. background: white;
  44. padding: 20px;
  45. border-radius: 8px;
  46. box-shadow: 0 4px 10px rgba(0,0,0,0.1);
  47. width: 300px;
  48. text-align: center;
  49. animation: fadeIn 0.5s ease-in-out;
  50. }
  51. h2 {
  52. margin-bottom: 20px;
  53. color: #333;
  54. }
  55. input[type="text"] {
  56. width: 100%;
  57. padding: 10px;
  58. margin: 10px 0;
  59. border: 1px solid #ddd;
  60. border-radius: 4px;
  61. transition: border-color 0.3s;
  62. }
  63. input[type="text"]:focus {
  64. border-color: #007bff;
  65. outline: none;
  66. }
  67. button {
  68. background-color: #007bff;
  69. color: white;
  70. border: none;
  71. padding: 10px;
  72. border-radius: 4px;
  73. cursor: pointer;
  74. transition: background-color 0.3s;
  75. }
  76. button:hover {
  77. background-color: #0056b3;
  78. }
  79. @keyframes fadeIn {
  80. from {opacity:0; transform: translateY(-20px);}
  81. to {opacity:1; transform: translateY(0);}
  82. }
  83. </style>
  84. </head>
  85. <body>
  86. <div class="container">
  87. <h2>Add a New Task</h2>
  88. <form action="addtask.php" method="post">
  89. <input type="text" name="title" placeholder="Task Title" required />
  90. <button type="submit"><i class="fas fa-plus"></i> Add Task</button>
  91. </form>
  92. </div>
  93. </body>
  94. </html>
  95.  
Success #stdin #stdout 0.03s 25516KB
stdin
Standard input is empty
stdout
Standard output is empty