How to implement comment reply delete function in PHP

Source: Internet
Author: User
How does PHP implement the comment reply delete function? This article is mainly for everyone to introduce the PHP implementation of the comment reply delete function, with a certain reference value, interested in small partners can refer to. We hope to help you.

Simple comment reply Delete function, the specific content is as follows

First, the database

Establish two tables, one is the Pinglun table, the other is the Huifu table

The effect is as follows:

The code is as follows:

1. Main Page main.php

<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 ><title> Untitled Document </title>

2. Comment Processing page pinglunchuli.php

<?php$zhangsan = $_post["Zhangsan"]; $content = $_post["Content"; $time = Date ("y-m-d h:i:s"); Require "DBDA.class.php"; $db = new Dbda (); $sql = "INSERT into Pinglun values (', ' {$zhangsan} ', ' {$content} ', ' {$time} ')"; $db->query ($sql); Header ("location:main.php");

3. Reply Processing page huifuchuli.php

<!--? Php$id = $_get["id"]; Pass the comment ID of the click reply $comment = $_post["Comment"]; Reply to content in text field $me = "Me"; Here is a definition of a person $times = Date ("y-m-d h:i:s"); Require "DBDA.class.php"; $db = new Dbda (); $sql = "INSERT into Huifu values (', ' {$id} ', ' {$me} ', ' {$Times} ', ' {$Comment} ')" ; $db--->query ($sql); Header ("location:main.php");

4. Delete Processing page delchuli.php

<?php$id = $_get["id"];require "DBDA.class.php"; $db = new Dbda (); $sql = "Delete from Pinglun where id= ' {$id} '"; if ($db-& Gt;query ($sql)) {   header ("location:main.php");} else{  echo "Delete failed! ";}

Related recommendations:

THINKPHP5 uploading images and generating thumbnail image methods

How to implement Simple automatic search box prompt function in PHP

How PHP Gets the audio file length

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.