我正在尝试制作一个用户照片删除脚本,用户可以删除自己的照片。问题是我希望用户确认,所以我在脚本中使用 $_GET 进行了确认。我不想当用户按下 Delete 键时,“Do you really want to blabla”这句话只出现在屏幕上。现在它只是在删除按钮和图像之后。
脚本:
if(($_GET['delete'] == '') || ($_GET['yes'] == '')) {
if($numrows != 0){
foreach ($result as $row) {
echo '
<div class="imgwrapklein">
'.$row['caption'].'<br />
<a href="show.php?photo='.$row['id'].'" title="'.$row['caption'].'"><img src="'.$row['location'].'" alt="'.$row['beschrijving'].'" /></a><br />
<a href="?delete='.$row['id'].'">Delete</a>
</div>
';
}
}else{
echo 'There are no pics!';
}
}else{
echo 'Something went wrong!';
}
if($_GET['delete'] != ''){
echo 'Are you sure you want to delete the picture <a href="?yes='.$_GET['delete'].'">Yes</a> - <a href="user-photo.php">No</a>';
}
if($_GET['yes'] != ''){
// hier komt het verwijder gedeelte
}