Hi Guys, I’ve been working my way through this book and up until this point its been pretty straight forward. There is an optional task to make the user confirm you want to delete the author in this chapter and I got stuck for the past hour trying to get it to work.
I’m wondering if someone can point out what I have done wrong here, everything works if I remove my extra code to confirm the action.
Index Page
if (isset($_POST['action']) and $_POST['action'] == 'Delete')
{
include 'confirm.delete.php';
exit();
}
if (isset($_POST['action']) and $_POST['action'] == 'Unconfirmed')
{
include 'authors.html.php'
exit();
}
if (isset($_POST['action']) and $_POST['action'] == 'Confirmed')
{
try
{ ...code that deletes user is here
Confirm Delete HTML(confirm.delete.php)
<?php include_once $_SERVER['DOCUMENT_ROOT'] . '/phpnin/includes/helpers.inc.php'; ?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Confirm Author Deletion</title>
</head>
<body>
<h1>Manage Authors</h1>
<p>Are you sure you want to delete author <?php htmlout($_POST['name']); ?>?</p>
<form action=" " method="post">
<div>
<input type="hidden" name="id" value="<?php echo ($_POST['id']); ?>">
<input type="submit" action="action" value="Confirmed">
<input type="submit" action="action" value="Unconfirmed">
</div>
</form>
</body>
</html>