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.

@$msg=$_GET[''msg''];
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''>";
while($nt=mysql_fetch_array($q)){
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.

/////////////////////////////////////////
$post_id=$_GET[''post_id''];
$f_name=$_GET[''f_name''];
$q=mysql_query("select * from cmt_post where post_id=$post_id ");
echo mysql_error();
$row=mysql_fetch_object($q);

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 ////////////////////

switch($row->status)
{
case "ns":
$nsck="checked";
$apvck="";

break;

case "apv":
$apvck="checked";
$nsck="";

break;


default:
$apvck="";
$nsck="";
break;

}


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''> 


</form>
";
///////////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.
@$todo=$_POST[''todo''];
if($todo=="status-up"){
$f_name=$_POST[''f_name''];
$post_id=$_POST[''post_id''];
$status=$_POST[''status''];
if($status=="del"){
$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 "); }

}else{
$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
else{
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


Subscribe

* indicates required
Subscribe to plus2net

    plus2net.com




    Haji

    21-02-2009

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

    11-06-2009

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

    12-08-2009

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

    25-08-2009

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

    01-09-2009

    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!
    Ecommerce77

    09-09-2009

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

    10-09-2009

    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

    01-10-2009

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

    04-04-2010

    this script is really good
    Dev Chuahan

    29-11-2012

    This post is complicated

    10-07-2022

    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 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer