From 32548af0309391f9ec666d258dc3f984054fe805 Mon Sep 17 00:00:00 2001 From: Aadhavan Srinivasan Date: Fri, 1 Sep 2023 15:03:50 -0500 Subject: [PATCH] Made backend changes --- undodeletelink.php | 5 ++++- updatelink.php | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/undodeletelink.php b/undodeletelink.php index 60cadf0..a44d745 100644 --- a/undodeletelink.php +++ b/undodeletelink.php @@ -9,11 +9,14 @@ $statement = $session->prepare('SELECT * FROM DATA WHERE user=? AND shortlink=? $result = $session->execute($statement,array('arguments' => array($_SESSION['user'],$_POST['link']))); $row_id = $result[0]['id']; - +if (empty($row_id) || empty($_POST['link']) || empty($_SESSION['user'])) { + http_response_code(500); +} $statement = $session->prepare('UPDATE data USING TTL 0 SET hell=false, shortlink=?, url=?, user=?, latitude=?, longitude=?, radius=? WHERE id=?;'); $new_result = $session->execute($statement,array('arguments' => array($_POST['link'], $result[0]['url'], $result[0]['user'], $result[0]['latitude'], $result[0]['longitude'], $result[0]['radius'], $row_id))); + http_response_code(204); ?> diff --git a/updatelink.php b/updatelink.php index 5e27e05..cdc2c04 100644 --- a/updatelink.php +++ b/updatelink.php @@ -5,8 +5,8 @@ require_once 'db.inc.php'; $session = init_cass_db(); //GET ROW ID -$statement = $session->prepare('SELECT * FROM DATA WHERE user=? AND shortlink=? AND url=? ALLOW FILTERING;'); -$result = $session->execute($statement,array('arguments' => array($_SESSION['user'],$_POST['old_link'], $_POST['old_url']))); +$statement = $session->prepare('SELECT * FROM DATA WHERE user=? AND shortlink=? ALLOW FILTERING;'); +$result = $session->execute($statement,array('arguments' => array($_SESSION['user'],$_POST['old_link']))); $row_id = $result[0]['id'];