PHP/Javascript
Moderator: General Moderators
PHP/Javascript
This might not be the right place to ask my question. btw I have written a web-blog on PHP and MySQL. At the end I have realized that I don't have any warning message for user before they delete their account, or contents. I know it can be done on javascript but I don't know much about it. Can any body give me a sample code for pop-up message that can be send before user decide to delete their account?
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
Re: PHP/Javascript
You can do something simple with the standard Javascript dialogs:
http://www.w3schools.com/js/js_popup.asp
Or you can try something fancier with a popup div.
http://www.w3schools.com/js/js_popup.asp
Or you can try something fancier with a popup div.
(#10850)
Re: PHP/Javascript
Thanks for the tips.
Here is the part of the PHP and JavaScript code that I have been trying to make it work.
My javascript is (filename javapopups.htm)
and I am trying to embed it into PHP code which looks like this
My goal is to have user delete the comment if they click OK on pop up dialog box, and refresh the page if not. Bug is it deletes in both circumstances. Any idea?
Here is the part of the PHP and JavaScript code that I have been trying to make it work.
My javascript is (filename javapopups.htm)
Code: Select all
<script type="text/javascript">
<!--
document.write(confirmation());
function confirmation() {
var answer = confirm(" Are you sure you want to delete?")
if (!answer){
window.location = "index.php";
}
document.write("Your content will be deleted!")
<!--}
}
</script>Code: Select all
if($_GET['what'] == delete_comm)
{
include("javapopups.htm");
echo $row_num = $_GET['which'];
echo $row_num . "<br>is row number ";
$delete_comment = "DELETE FROM comment where commentid = $row_num";
$delete_comment_query = mysql_query($delete_comment);
if(!delete_comment_query)
{
echo "Error on deleting ".mysql_error();
} else
{
echo "Comment deleted! ";
echo "<meta http-equiv = \"refresh\" content = \"0; URL=index.php?page=$pageNum\">";
}
}
My goal is to have user delete the comment if they click OK on pop up dialog box, and refresh the page if not. Bug is it deletes in both circumstances. Any idea?
Re: PHP/Javascript
Please somebody help he in this issue.