From 0f2e5d6bf4b3225e4057ecf8e271952c6cad0b14 Mon Sep 17 00:00:00 2001 From: Zach Date: Thu, 25 Apr 2019 12:56:17 -0400 Subject: [PATCH] updates --- AddNewItem/addNewItem.php | 3 -- AddNewItem/index.php | 19 +++++++++---- ToDoList/editTask.php | 53 ++++++++++++++++++++--------------- ToDoList/editTaskHandling.php | 21 ++++++++++++++ ToDoList/index.php | 12 ++++---- databaseFunctions.php | 2 +- 6 files changed, 73 insertions(+), 37 deletions(-) create mode 100644 ToDoList/editTaskHandling.php diff --git a/AddNewItem/addNewItem.php b/AddNewItem/addNewItem.php index a7d9ccd..fab682b 100644 --- a/AddNewItem/addNewItem.php +++ b/AddNewItem/addNewItem.php @@ -2,9 +2,6 @@ require '../database-info.php'; require '../databaseFunctions.php'; - - - $name = $_POST['name']; $description = $_POST['description']; $dueDate = $_POST['duedate'] . " " . date("H:i:s"); diff --git a/AddNewItem/index.php b/AddNewItem/index.php index e08060a..03b3548 100644 --- a/AddNewItem/index.php +++ b/AddNewItem/index.php @@ -1,7 +1,7 @@
@@ -16,8 +16,7 @@ session_start(); if(isset($_SESSION['ResultMessage1'])){ echo $_SESSION['ResultMessage1']; - exit(); - } + } ?>
@@ -42,6 +41,16 @@
+ diff --git a/ToDoList/editTask.php b/ToDoList/editTask.php index 46fa561..1ff2b4d 100644 --- a/ToDoList/editTask.php +++ b/ToDoList/editTask.php @@ -1,28 +1,37 @@ execute (); - } -*/ -if(isset($_GET['editTaskItem'])){ - $id = $_GET['editTaskItem']; +require ('../header.php'); +require ('../database-info.php'); +require ('../databaseFunctions.php'); + + $id = $_GET['id']; $sql = selectToDoListItem($id); - $stmt = $pdo-prepare ($sql); + $stmt = $pdo->prepare ($sql); $stmt->execute (); - } -?> + $row = $stmt -> fetch(); - - - +?> +
+ + +
+ + +
+
- + +
+
+ + +
+ + +Cancel Changes - - \ No newline at end of file +
+ \ No newline at end of file diff --git a/ToDoList/editTaskHandling.php b/ToDoList/editTaskHandling.php new file mode 100644 index 0000000..0d867b3 --- /dev/null +++ b/ToDoList/editTaskHandling.php @@ -0,0 +1,21 @@ +prepare($sql); + $stmt->bindValue (':name', $name); + $stmt->bindValue (':description', $description); + $stmt->bindValue (':date', $dueDate); + $stmt->execute (); +} catch(Exception $e){ + echo "Error while updating data " . $e->getMessage() , "\n"; +} +echo "Successfully updated item! "; + + +?> \ No newline at end of file diff --git a/ToDoList/index.php b/ToDoList/index.php index 4ea0424..a94fa96 100644 --- a/ToDoList/index.php +++ b/ToDoList/index.php @@ -18,12 +18,12 @@ $stmt = $pdo->prepare ($sql); $stmt->execute (); } -if(isset($_GET['editTaskItem'])){ +/*if(isset($_GET['editTaskItem'])){ $id = $_GET['editTaskItem']; $sql = editTaskItem($id); $stmt = $pdo->prepare ($sql); $stmt->execute (); - } + }*/ ?> @@ -38,7 +38,7 @@ $result->execute(); ?> - + @@ -53,7 +53,7 @@ - + @@ -77,14 +77,14 @@ function editItem(){ let params = `scrollbars=yes,resizable=no,status=no,location=no,toolbar=no,menubar=no, width=500,height=500,left=0,top=0`; -open("/PHP-ToDo/ToDoList/editTask.php?id=", 'test', params); +open("/PHPToDo/ToDoList/editTask.php?id=", 'test', params); } function addNewItem(){ let params = `scrollbars=yes,resizable=yes,status=no,location=no,toolbar=no,menubar=no, width=500,height=650,left=0,top=0`; -open('/PHP-ToDo/AddNewItem', 'test', params); +open('/PHPToDo/AddNewItem', 'test', params); } \ No newline at end of file diff --git a/databaseFunctions.php b/databaseFunctions.php index 68c3484..1447f6a 100644 --- a/databaseFunctions.php +++ b/databaseFunctions.php @@ -7,7 +7,7 @@ function selectToDoList(){ } function selectToDoListItem($id){ - $sqlQuery = "SELECT * FROM todolist WHERE ToListID = $id;"; + $sqlQuery = "SELECT * FROM todolist WHERE ToDoID = $id;"; return $sqlQuery; }
Edit