Php implements the comment reply deletion function, and php implements comment reply

Source: Internet
Author: User

Php implements the comment reply deletion function, and php implements comment reply

Simple comment reply delete function, details:

I. Databases

Create two tables: pinglun and huifu.

The effect is as follows:

The Code is as follows:

1. main. php on the home page

<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. huifuchuli. php

<! --? Php $ id = $ _ GET ["id"]; // upload the reply Comment id $ Comment =$ _ POST ["Comment"]; // reply to the content in the text field $ me = "me"; // here we define 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 the processing page delchuli. php

<? Php $ id = $ _ GET ["id"]; require "DBDA. class. php "; $ db = new DBDA (); $ SQL =" delete from Pinglun where id = '{$ id }'"; if ($ db-> query ($ SQL) {header ("location: main. php ");} else {echo" failed to delete! ";}

The above is all the content of this article. I hope it will be helpful for your learning and support for helping customers.

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.