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.