Site admin approval of comments posted by visitors script

You can read the main tutorial on posting comment here. We will discuss how the admin are works in posting comment script. The main purpose of admin area is to approve or delete the postings of the visitors. By default once the comments are posted the status of the posting remains at ns ( not seen ). Records with status equal to ns are not displayed in public area. Inside the admin area site admin after login can view the all the comments or only list the comments which are in ns status ( not seen ). While viewing the list site admin can see name, email date of post etc along with status of the posting. Admin can click the link Details and see full details of the post. Here admin can change the status to apv ( approved ) or can delete the post. Here any approved posting ( status = apv) can be changed to not seen ( status = ns ).

In list.php page all the records ( or posts ) get listed in the order of date of post. If required admin can go to a page where not approved ( status =ns) records are only displayed. Here is the code for list.php page, a simple collection of records from the table.

if(isset($msg) and strlen($msg) >1 ){
echo "<span style=''background-color: #FFFF00''>$msg</span>";


$q=mysql_query("select * from cmt_post order by dt ");

echo "<table width=''100%'' border=''0'' cellspacing=''1'' cellpadding=''0''>";
echo "<tr ><td><b>id</b>:$nt[post_id] <b>name</b>:$nt[name] <b>email</b>:$nt[email] <b>status</b>:$nt[status] <a href=''list-dtl.php?post_id=$nt[post_id]&f_name=list.php''>Details</a></td><td align=right>".date("d-m-Y",strtotime($nt[''dt'']))."</td></tr>";
echo "<tr ><td colspan=2>$nt[dtl]</td></tr>";

echo "</table>";
Admin can view the full details with status change option by clicking the detail link available with each posting. On clicking that admin can visit the page list-dtl.php page where posting details with option to change the status will be displayed. Here is the code.

$q=mysql_query("select * from cmt_post where post_id=$post_id ");
echo mysql_error();

echo "<table width=''100%'' border=''0'' cellspacing=''1'' cellpadding=''0''>";
echo "<tr><td><b>id</b>:$row->post_id <b>name</b>:$row->name <b>email</b>:$row->email <b>status</b>:$row->status</td><td align=right>".date("d-m-Y",strtotime($row->dt))."</td></tr>";
echo "<tr ><td colspan=2>$row->dtl</td></tr>";
echo "</table>";
echo "<hr>";

//////////// Updation starts ////////////////////

case "ns":


case "apv":




echo "<form method=post action=''list-dtlck.php''>
<input type=hidden name=''todo'' value=''status-up''>
<input type=hidden name=f_name value=''$f_name''>
<input type=hidden name=post_id value=$post_id>
<input type=radio name=status value=''ns'' $nsck>Not Seen 
<input type=radio name=status value=''apv'' $apvck>Approved 
<input type=radio name=status value=''del'' >Delete 

<input type=submit value=''Update''> 

///////////Updation ends //////

Once the admin submit the form for change of status the form data goes to list-dtlck.php page. Here all the form data collected and first checked if delete options is selected. Record is deleted if delete option is given or the status is changed as per the selection. After the changes the page automatically redirect to list.php page with a message displayed at the top of the list.php page. Here is the code.
$q=mysql_query("delete from cmt_post where post_id=$post_id");
if(mysql_affected_rows() <> 1){
header ("Location: $f_name?msg=<br>Not able to delete Record "); 
}else{header ("Location: $f_name?msg=<br>Record  deleted "); }

$q=mysql_query("update  cmt_post set status=''$status'' where post_id=$post_id ");
echo mysql_error();
if(mysql_affected_rows() <> 1){
header ("Location: $f_name?msg=<br>Not able to update Record "); 
}else{header ("Location: $f_name?msg=<br>Record updated "); }

}// end of if else
}// end of todo checking
header ("Location: $f_name?msg=<br>Data Problem"); 
With this let us learn How to install the script in part 3

Download the full script here
Subscribe to our YouTube Channel here


* indicates required
Subscribe to plus2net



    I need a instruction on how to install commenting script and how to embed into every page. thanks alot


    Hi friends, Nice to read this blog. From the blog i got many informative points.


    Great Post. thanks, these are really useful informations.
    Vill Garcia


    hea, this tutorial helps me a lot. thanks please post more tutorial
    Ecommerce web design


    Having written articles that require this much work, I commend you for your service to the future bloggers. I am sure they will appreciate it! Great job. Some great information to be absorbed in this post. Thanks!


    Excellent post. These tips are really useful for me. It really helped me a lot. Keep blogging.


    Hello.... This is a great tutorial for me as it is about commenting script. It helps me a lot. I need a instruction on how to install commenting script. Plz help me out. Keep blogging.
    dedicated hosting


    A bunch of informative knowledge.A very useful topic for newbies.Great post...


    this script is really good
    Dev Chuahan


    This post is complicated


    Comment box Script in php with Reply and approve by admin

    Post your comments , suggestion , error , requirements etc here .

    We use cookies to improve your browsing experience. . Learn more
    HTML MySQL PHP JavaScript ASP Photoshop Articles FORUM . Contact us
    ©2000-2023 All rights reserved worldwide Privacy Policy Disclaimer