Hi!
I have a problem with deleting a row in a table.
When someone has booked something they might want to delete the booking.
How can I fix this with a script so the user can delete it with a submit button or something else.
When they logged in the will see the booking they have done and if they want they can delete it there as well. I do hope someone can help me with this.
The tabel is called "book"
The script when they logged in:
<?php // <-- Översta raden längst till vänster
session_start();
// Kolla om inloggad = sessionen satt
if (!isset($_SESSION['sess_user'])){
header("Location: index.php");
exit;
}
?>
I have this script but I cant get it right
if (isset($_GET['delete']) && isset($_SESSION['sess_user'])) {
$sql = "DELETE FROM book WHERE id={$_GET['delete']}";
mysql_query($sql);
header("Location: book.php");
exit;
}
<?php
if (isset($_SESSION['sess_user'])) {
<a href="book.php?delete=<?=$row['id']?>">Delete</a>
}
?>
Best
Runar