Body
In this repository we will create a Simple To-Do List App using PHP. PHP is a server-side scripting language designed primarily for web development. Using PHP, you can let your user directly interact with the script and easily to learned its syntax. It is mostly used by newly coders for its user-friendly environment.
First you have to download & install XAMPP or any local server that run PHP scripts. Here's the link for XAMPP server https://www.apachefriends.org/index.html.
And this is the link for the bootstrap that has been used for the layout https://getbootstrap.com/.
Open your database web server then create a database name in it db_task
. After that, click Import
then locate the database file inside the folder of the application then click ok.
Open your any kind of text editor(notepadd++, etc..). Then just copy/paste the code below then name it conn.php.
$conn = new mysqli("localhost", "root", "", "db_task");
if(!$conn){
die("Error: Cannot connect to the database");
}
Note: Start PHP Opening and Closing tag
This is where we will create a simple form for our application. To create the forms simply copy and paste it into you text editor, then save it as shown below.
add_query.php
require_once 'conn.php';
if(isset($_POST['add'])){
if($_POST['task'] != ""){
$task = $_POST['task'];
$conn->query("INSERT INTO `task` (`task`)VALUES('$task')");
header('location:index.php');
}
}
update_task.php
require_once 'conn.php';
if($_GET['task_id'] != ""){
$task_id = $_GET['task_id'];
$conn->query("UPDATE `task` SET `status` = 'Done' WHERE `task_id` = $task_id") or die(mysqli_errno($conn));
header('location: index.php');
}
delete_query.php
require_once 'conn.php';
if($_GET['task_id']){
$task_id = $_GET['task_id'];
$conn->query("DELETE FROM `task` WHERE `task_id` = $task_id") or die(mysqli_errno($conn));
header("location: index.php");
}
There you have it we successfully created a Simple To-Do List App using PHP. I hope that this simple project helps you to what you are looking for. For more updates and projects just kindly visit my profile. Sujon-Ahmed
Enjoy Coding!!!