Integrative Programming Technology I PHP
Integrative Programming Technology I PHP
PROGRAMMING
This project will create a basic to-do list application using PHP.
1. Create a File:
Create a new file named todo_list.php.
<?php
// Initialize an array to store tasks
$tasks = array();
// Check if the form has been submitted
if (isset($_POST['submit'])) {
// Get the task from the form
$new_task = $_POST['task'];
// Add the task to the array
$tasks[] = $new_task;
// Save the tasks to a file (optional)
file_put_contents('tasks.txt', serialize($tasks));
}
// Load tasks from file (if exists)
if (file_exists('tasks.txt')) {
$tasks = unserialize(file_get_contents('tasks.txt'));
}
?>
<!DOCTYPE html> <button type="submit"
<html> name="submit">Add</button>
<head> </form>
<title>To-Do List</title> <ul>
</head> <?php foreach ($tasks as $task) :
<body> ?>
<li>
<h1>To-Do List</h1> <?php echo $task;
<form method="post" action=""> ?>
</li> <?php endforeach;
<input type="text" name="task"
?>
placeholder="Add a task">
</ul>
</body>
</html>
WE APPRECIATE
YOUR TIME!
Thank you for exploring the world of programming with us. We
sincerely hope this presentation has inspired you to dive deeper into
this exciting and ever-evolving field.