I am trying to remove a record from my database. As of now the correct id is passing through as I can see in the Query String Parameters and I am not getting any errors. However, the row is not being deleted, im starting to think it is just a some syntax error but I am unsure.
remove-like.php
<?php
$id=isset($_GET['id']) ? $_GET['id'] : die('ERROR: id not found.');
if($_POST) {
include 'connectPDO.php';
try {
$query = "DELETE FROM likes WHERE id = ?";
$stmt = $con->prepare($query);
$stmt->bindParam(1, $id);
$stmt->execute();
} catch (PDOException $exception) {
die('ERROR: ' . $exception->getMessage());
}
}
This is the service file where I am calling it.
forum.service.ts
removeLike(id: string) {
return this.http.delete(`${this.baseUrl}/remove-like.php?id=${id}`);
}
Then this is the part where I am calling that function in my component.
topics.component.ts
clickDislike() {
this.forumService.removeLike(this.dataService.getToken() + 'topic' + this.forumService.getLikeToken()).subscribe(result => {
this.ngOnInit();
})
}