PHP ToDo List Report
PHP ToDo List Report
ABSTRACT
This project presents a simple yet effective To-Do List application developed using PHP and HTML5. It
demonstrates basic CRUD operations and serves as a fundamental example of PHP-MySQL web integration.
OBJECTIVE
The primary objective of this project is to develop a task management tool that allows users to add, view, and
delete to-do items through a web interface, using PHP for back-end logic and MySQL for data storage.
INTRODUCTION
To-Do Lists are simple yet powerful tools for organizing daily tasks. This project demonstrates how such an
application can be built using PHP, a popular server-side scripting language, along with MySQL and HTML5.
METHODOLOGY
1. Tools Used:
2. Process:
CONCLUSION
The PHP Simple To-Do List project effectively demonstrates basic web development concepts. It can be
expanded with user authentication, task priorities, and deadlines in the future.
CODE
db.php
<?php
$servername = "localhost";
$username = "root";
$password = "";
$database = "todo_app";
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
?>
index.php
<?php
include("db.php");
$result = mysqli_query($conn, "SELECT * FROM todos ORDER BY id DESC");
?>
<!DOCTYPE html>
<html>
<head>
<title>Simple To-Do List</title>
<link rel="stylesheet" href="css/style.css">
</head>
<body>
<div class="container">
<h1>To-Do List</h1>
<form method="POST" action="add.php">
<input type="text" name="task" required placeholder="Add new task">
<button type="submit">Add</button>
</form>
<ul>
<?php while ($row = mysqli_fetch_assoc($result)) { ?>
<li>
<?php echo htmlspecialchars($row['task']); ?>
<a href="delete.php?id=<?php echo $row['id']; ?>">Delete</a>
PHP Simple To-Do List Project Report
</li>
<?php } ?>
</ul>
</div>
</body>
</html>
add.php
<?php
include("db.php");
if (isset($_POST['task'])) {
$task = mysqli_real_escape_string($conn, $_POST['task']);
mysqli_query($conn, "INSERT INTO todos (task) VALUES ('$task')");
}
header("Location: index.php");
exit();
?>
delete.php
<?php
include("db.php");
if (isset($_GET['id'])) {
$id = (int)$_GET['id'];
mysqli_query($conn, "DELETE FROM todos WHERE id = $id");
}
header("Location: index.php");
exit();
?>
css/style.css
body {
font-family: Arial, sans-serif;
background-color: #f4f4f4;
padding: 20px;
}
.container {
max-width: 500px;
margin: auto;
background: white;
padding: 20px;
border-radius: 10px;
box-shadow: 0 0 10px rgba(0,0,0,0.1);
}
PHP Simple To-Do List Project Report
input[type=text] {
padding: 10px;
width: 70%;
margin-right: 10px;
}
button {
padding: 10px 20px;
}
ul {
list-style-type: none;
padding: 0;
}
li {
margin: 10px 0;
display: flex;
justify-content: space-between;
}