评论框使用PHP [英] comment box using php

查看:75
本文介绍了评论框使用PHP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





即时通讯我试图在php中发表评论框..它正在工作,但之前的评论在我们输入新评论时被删除..但它存储了所有评论在数据库中..如何在同一页面显示所有评论plz help mee



这里是代码..





im trying to make comment box in php.. its working but previous comments was deleted when we type new comment.. but it stores all comments in database.. how to display all comments in the same page plz help mee

here is the code..

<?php

mysql_connect("localhost","root","");

mysql_select_db("cmtdb");

error_reporting(E_ALL ^ E_NOTICE);

$notify = "";

$name=$_POST['name'];

$comment=$_POST['comment'];

$submit=$_POST['submit'];

if(isset($_POST['notify_box'])){ $notify = $_POST['notify_box']; }

$dbLink = mysql_connect("localhost", "root", "");

    mysql_query("SET character_set_client=utf8", $dbLink);

    mysql_query("SET character_set_connection=utf8", $dbLink);



if($submit)

{

if($name&&$comment)

{

$insert=mysql_query("INSERT INTO comment (name,comment) VALUES ('$name','$comment') ");

}

else

{

echo "please fill out all fields";

}

}

?>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Comment box</title>
</head>
<body>
<center>
<form action="comment.php" method="POST">
<table>
<tr><td>Name: <br><input type="text" name="name"/></td></tr>
<tr><td colspan="2">Comment: </td></tr>
<tr><td colspan="5"><textarea name="comment" rows="10" cols="50"></textarea></td></tr>
<tr><td colspan="2"><input type="submit" name="submit" value="Comment"></td></tr>
</table>
</form>

<?php echo $name;?><br>
<?php echo $comment;?>

<?php

$dbLink = mysql_connect("localhost", "root", "");

mysql_query("SET character_set_results=utf8", $dbLink);

mb_language('uni');

mb_internal_encoding('UTF-8');



$sql="SELECT * FROM comment";

$getquery= mysql_query($sql);

while($row= mysql_fetch_array($getquery))

{

$name=$row['name'];

$comment=$row['comment'];

}

?>

</body>
</html>

推荐答案

通知 = ;

notify = "";


name =
name=


_POST [' name'];

_POST['name'];


这篇关于评论框使用PHP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆