Very quick and dirty, but you should get the idea. Make sure there is NO output to the browser, not even white space, before the header() call.
<?
if ( $confirm == "on") {
delete it . . .
header("Location: other_page");
} elseif ( $pagetodelete != "" ) {
print "<a href='$PHP_SELF?confirm=on&pagetodelete=$pagetodelete'>Are you sure?</a>";
} else {
print "<a href='$PHP_SELF?pagetodelete=whatever'>Click to delete this</a>";
}
?>