如何使用PHP和mysql编写注释框 [英] How to code comment box with PHP and mysql
本文介绍了如何使用PHP和mysql编写注释框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在开发一个带有php和mysql的评论框,但我现在的问题是如何在用户输入评论后发表评论。到目前为止我的php和mysql将评论保存在数据库中,但我想要它保存到数据库后在我的网页上可见,我不知道代码,我需要帮助。
我试过的:
i am developing a comment box with php and mysql,but my problem now is how to post the comment after user has enter their comment.so far i my php and mysql that save the comment in the database,but i want it to be visible on my webpage after it is save to database,i don't know the code for that,i need help.
What I have tried:
<pre><!DOCTYPE html>
<html>
<head>
<title>
commenting system
</title>
</head>
<body>
<form action = "cm.php" method = "POST">
<input type = "text" name = "fname" placeholder = "Name"><br><br>
<input type = "text" name = "website" placeholder = "website"><br><br>
<textarea type = "text" name = "scomment" rows = "6" col = "250" placeholder = "comment here....">
</textarea>
<button type = "submit">SUBMIT</button>
</form>
</body>
</html>
<pre lang="PHP"><pre lang="PHP"><pre lang="PHP"><pre lang="PHP"><pre lang="PHP">
cm.php
cm.php
<?php
include 'db.php';
$fname = $_POST['fname'];
$website = $_POST['website'];
$scomment = $_POST['scomment'];
$sql = "INSERT INTO client (fname, website, comment) VALUES ('$fname', '$website', '$scomment')";
$result = $con->query($sql);
header("Location:index.php");
?>
db.php
db.php
<?php
$con = mysqli_connect("localhost", "root", "", "comment");
if(!$con){
die("connection error".mysqli_connect_error());
}
?>
?>
推荐答案
fname =
_POST ['fname'];
_POST['fname'];
website =
website =
这篇关于如何使用PHP和mysql编写注释框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文