├── Dockerfile ├── README.md ├── index.php └── simple_todo.sql /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM php:8.1-apache 2 | RUN apt-get update && docker-php-ext-install mysqli pdo && docker-php-ext-enable mysqli pdo 3 | COPY . /var/www/html/ 4 | 5 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # 3tier_todo_app 2 | -------------------------------------------------------------------------------- /index.php: -------------------------------------------------------------------------------- 1 | alert('Todos Inserted');"; 11 | } 12 | }else{ 13 | echo ""; 14 | } 15 | 16 | 17 | } 18 | 19 | if (isset($_POST['todo']) && !empty($_POST['id']) ) { 20 | $id = $_POST['id']; 21 | $todo = $_POST['todo']; 22 | if(UpdateTodo($id,$todo,$connection)){ 23 | echo ""; 24 | } 25 | 26 | } 27 | 28 | if (isset($_GET['delete_id'])) { 29 | $id = $_GET['delete_id']; 30 | if (DeleteTodo($id,$connection) == true) { 31 | echo ""; 32 | } 33 | 34 | } 35 | if (isset($_GET['marking_id'])) { 36 | $id = $_GET['marking_id']; 37 | if (CompleteTodo($id,$connection)== true) { 38 | echo ""; 39 | } 40 | } 41 | 42 | function InsertTodo($todo,$connection) 43 | { 44 | 45 | $query = "INSERT INTO todos set todo = '$todo' "; 46 | $result = mysqli_query($connection,$query); 47 | if ($result == true) { 48 | return true; 49 | }else{ 50 | return false; 51 | } 52 | } 53 | 54 | function DeleteTodo($id,$connection) 55 | { 56 | $query = "Delete from todos where id = '$id' "; 57 | $result = mysqli_query($connection,$query); 58 | if ($result == true) { 59 | return true; 60 | }else{ 61 | return false; 62 | } 63 | } 64 | 65 | 66 | function CompleteTodo($id,$connection) 67 | { 68 | $query = "UPDATE todos set completed = 1 where id = '$id'"; 69 | $result = mysqli_query($connection,$query); 70 | if ($result == true) { 71 | return true; 72 | }else{ 73 | return false; 74 | } 75 | 76 | } 77 | if(isset($_POST['update'])){ 78 | $id = $_POST['update_id']; 79 | $data = GetTodo($id,$connection); 80 | } 81 | function GetTodo($id,$connection) 82 | { 83 | $query = "select * from todos where id = '$id' "; 84 | $result = mysqli_query($connection,$query); 85 | if ($result == true) { 86 | return mysqli_fetch_assoc($result); 87 | }else{ 88 | return false; 89 | } 90 | 91 | } 92 | function UpdateTodo($id,$todo,$connection) 93 | { 94 | $query = "Update todos set todo = '$todo' where id = '$id' "; 95 | $result = mysqli_query($connection,$query); 96 | if (mysqli_error($connection)) { 97 | die(mysqli_error($connection)); 98 | } 99 | } 100 | ?> 101 | 102 | 103 | 104 | 105 |
106 |