2014-04-25 125 views
1

我做了登錄註銷表單,如果要刪除我的帳戶,我有可能性。如果我按下按鈕Sterge cont彈出式窗口會顯示apear並詢問我是否真的要刪除此帳戶。如果我點擊NU該帳戶不會被刪除,該窗口將關閉,但如果我點擊DA該帳戶將被刪除。關閉彈出窗口並重定向到另一頁

,我要解決的問題是,如果我打DA窗口會做PHP刪除帳戶的部分,之後將關閉和重定向我的網頁profil.phpindex.php?accountdeleted

This是它的外觀的用戶配置文件。
This是它如何看起來彈出窗口。

回答

1

您可以將popup事件關閉。在your_popup.php

profil.php

<button type="button" id="delete" onclick="window.open('your_popup.php', 'popup', 'height=400, width=400, top=0, left=0,resizable=yes,scrollbars=yes,toolbar=yes,menubar=no')">Delete</button> 

然後:你可以做這樣的事情

<?php 

if(isset($_POST['confirm_delete'])) { 
    // do you query or database delete, etc. 


    // at the end 
    echo '<script type="text/javascript">self.close(); opener.location.href = "http://localhost/citate_celebre/profil.php";</script>'; 
} 

?> 

<form method="POST" action="popup.php"> 
    <button type="button" id="cancel_delete">Cancel</button> 
    <button type="submit" name="confirm_delete">Delete</button> 
</form> 
+0

非常有益的!謝謝! – Filip

0

確保您有彈出窗口實例。

var popupWindow = window.open(...) //Open the popup 
    popupWindow.onbeforeunload = function(e) { 
    window.location.href = 'index.php?accountdeleted'; //redirect to new page 
}; 
相關問題