I have one page where i can Approve or Delete comments which user submitted on my blog (I built the blog without Wordpress with PHP and MySQL) Now everything is working fine and i just need help with one question. I'm deleting and approving comments from one page means i have separate queries but both are on same page and i want to auto-refresh page only once after submitting of form, below is code which i has. For approving comment -
<?php
if(isset($_POST['approve_cmt'])) {
$id = $_POST['id'];
$sql = "UPDATE `blog_comments` SET `status` = '1' WHERE comment_id = '$id'";
$res = mysql_query($sql) or die(mysql_error());
if ($res == 1) {
echo "<script type='text/javascript'>alert('Comment approved!') window.location.reload(); </script>";
} else {
echo "<script type='text/javascript'>alert('Failed to approve comment') window.location.reload(); </script>";
}
}
;?>
for deleting comment
<?php
if(isset($_POST['delete_cmt'])) {
$id = $_POST['id'];
$sql = "DELETE FROM `blog_comments` WHERE `comment_id` = '$id'";
$res = mysql_query($sql) or die(mysql_error());
if ($res == 1) {
echo "<script type='text/javascript'>alert('comment deleted') window.location.reload(); </script>";
} else {
echo "<script type='text/javascript'>alert('unable to delete comment') window.location.reload(); </script>";
}
}
;?>