diff --git a/database/deleteChatroomMessage.php b/database/deleteChatroomMessage.php index fcfb394..14a5f8a 100644 --- a/database/deleteChatroomMessage.php +++ b/database/deleteChatroomMessage.php @@ -1,4 +1,4 @@ -prepare("SELECT * FROM users WHERE token = ? AND username = ?"); -$stmt->bind_param("ss", $token, $username); +$stmt = $conn0->prepare("SELECT id FROM users WHERE username = ? LIMIT 1"); +$stmt->bind_param("s", $username); $stmt->execute(); $result = $stmt->get_result(); $row = $result->fetch_assoc(); -if (!$row) exit; +if ($result->num_rows != 1) exit; $stmt->close(); $user_id = $row["id"]; + +$stmt = $conn1->prepare("SELECT 1 FROM userdata WHERE token = ? AND id = ? LIMIT 1"); +$stmt->bind_param("si", $token, $user_id); +$stmt->execute(); +$result2 = $stmt->get_result(); +if ($result2->num_rows != 1) exit; +$stmt->close(); + $time = time(); -$stmt = $conn->prepare("UPDATE chats SET deleted_at = ? WHERE userId = ? AND id = ?"); +$stmt = $conn1->prepare("UPDATE chats SET deleted_at = ? WHERE userId = ? AND id = ?"); $stmt->bind_param("iii", $time, $user_id, $id); $stmt->execute(); $stmt->close(); -$conn->close(); \ No newline at end of file +$conn0->close(); +$conn1->close(); \ No newline at end of file