I made a delete query. The delete query is used to delete posts made by the admin but if I click on the the delete button I go to a screen with object not found. I will show the delete query:
include '../db/db.php';
$id = $_GET['0'];
$query = "DELETE FROM pages WHERE paginaNummer = :id";
$stmt = $dbcon->prepare($query);
$stmt->execute(array(':id' => $id));
$row=$stmt->fetch();
header("Location: http://127.0.0.1/cmsFenB/index.php");
Here is the db connection:
<?php
try {
$db = new PDO('mysql:host=localhost;dbname=register', 'root', '');
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
} catch(PDOException $e) {
echo $e->getMessage();
die();
}
?>
And here is the link that referrers to this script:
echo " <a class='delete' href='fucntions/admin/delete.php?id=" . $pageNumber . " '>Delete</a>";
I hope you can help me out with this problem.
You have a typo in the referrer link. It should look like this:
echo " <a class='delete' href='functions/admin/delete.php?id=" . $pageNumber . " '>Delete</a>";
$id=$_GET['0'];
? I think you meant something like $_GET['id']
$id=$_GET['id'];
$query = "DELETE FROM pages WHERE paginaNummer = :id";
$stmt = $db->prepare($query);
$stmt->execute(array(':id' => $id));