我想使用戶照片刪除腳本,用戶可以刪除自己的照片。 問題是我想讓用戶確認,所以我在$ _GET中做了腳本。我不想當用戶按下刪除時,只有在屏幕上顯示「你真的想要說什麼」這句話。現在它只是在刪除按鈕和圖像之後。卡住不顯示文本與GET
腳本:
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
}
爲什麼不只是使用JavaScript來顯示確認對話框? – tborychowski
@agree與tborychowski JavaScript是更簡單 – Parfait
如果(確認(「你確定要刪除照片?」)){// 做一些 } – Parfait