我有一个仍在建设中的网站。
我在 PHP 中有一个评论框,它链接到我的 godaddy 帐户上的 mysql 数据库。
在调试时,我发现在您发表评论并刷新评论后,由于某种原因再次出现。
该网站的链接是:www.borgcarr.com
有两个php代码;一个在开头,一个在我需要它显示评论的地方。
HTML 代码:
<?php
mysql_connect("localhost","root","root");
mysql_select_db("Comment_Box");
$name=$_POST['name'];
$comment=$_POST['comment'];
$submit=$_POST['submit'];
$dbLink = mysql_connect("localhost", "root", "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_Table (name,comment) VALUES ('$name','$comment') ");
}
else
{
echo "<script>alert('Please fill out all fields.');</script>";/*echo "please fill out all fields";*/
}
}
?>
<html>
<head><title>Law Website</title>
<link href='css/style.css' type='text/css' rel='stylesheet' />
<link href="scripts/6/js-image-slider.css" rel="stylesheet" type="text/css" />
<script src="scripts/6/js-image-slider.js" type="text/javascript"></script>
</head>
<body>
<center>
<div id="sitewrapper">
<div id="header">
<div id="header_content_left">
Maltese Law
</div>
</div>
<div id="menu">
<div id="menu_left">
<div id="sliderFrame">
<div id="slider">
<img src="images/court1.jpg" alt="" />
<img src="images/court2.jpg" alt="" />
<img src="images/court3.jpg" alt="" />
<img src="images/court4.jpg" alt="" />
<img src="images/court5.jpg" alt="" />
<img src="images/court6.jpg" alt="" />
</div>
</div>
</div>
<div id="menu_right">
<div id="menu_right_top">
<ul id="menulist">
<li><a href src="#"><img src="images/buttons/articles_btn.png" onmouseover="this.src='images/buttons/articles_btn_hover.png'" onmouseout="this.src='images/buttons/articles_btn.png'" alt="Articles"/></a></li>
<li><a href src="#"><img src="images/buttons/interviews_btn.png" onmouseover="this.src='images/buttons/interviews_btn_hover.png'" onmouseout="this.src='images/buttons/interviews_btn.png'" alt="Articles"/></a></li>
<li><a href src="#"><img src="images/buttons/events_btn.png" onmouseover="this.src='images/buttons/events_btn_hover.png'" onmouseout="this.src='images/buttons/events_btn.png'" alt="Events" /></a></li>
<li><a href src="#"><img src="images/buttons/team_btn.png" onmouseover="this.src='images/buttons/team_btn_hover.png'" onmouseout="this.src='images/buttons/team_btn.png'" alt="The Team" /></a></li>
<li><a href src="#"><img src="images/buttons/contact_btn.png" onmouseover="this.src='images/buttons/contact_btn_hover.png'" onmouseout="this.src='images/buttons/contact_btn.png'" alt="Contact Us" /></a></li>
<li><a href src="#"><img src="images/buttons/home_btn.png" onmouseover="this.src='images/buttons/home_btn_hover.png'" onmouseout="this.src='images/buttons/home_btn.png'" alt="Home" /></a></li>
</ul>
</div>
<div id="menu_right_bottom"><hr width="560px"></div>
</div>
</div>
<div id="content">
<div id="content_left">
<p>
<h2>News</h2>
Lorem Ipsum is simply dummy
text of the printing and
typesetting industry. Lorem
Ipsum has been the industry's s
tandard dummy text ever since the
1500s, when an unknown printer too
k a galley of type and scrambled i
t to make a type specimen book. It
has survived not only five centuri
es, but also the leap into electro
nic typesetting, remaining essenti
ally unchanged. It was popularised
in the 1960s with the release of L
etraset sheets containing Lorem Ip
sum passages, and more recently wi
th desktop publishing software lik
e Aldus PageMaker including versio
ns of Lorem Ipsum.
</p>
</div>
<div class="verticalLine">
<font style="color: #2a3035;">.</font>
</div>
<div id="content_right_top"><h1>Have your say...</h1><hr>
<?php
$dbLink = mysql_connect("localhost", "root", "root");
mysql_query("SET character_set_results=utf8", $dbLink);
mb_language('uni');
mb_internal_encoding('UTF-8');
$getquery=mysql_query("SELECT * FROM Comment_Table ORDER BY id DESC");
while($rows=mysql_fetch_assoc($getquery))
{
$id=$rows['id'];
$name=$rows['name'];
$comment=$rows['comment'];
echo $name . '<br/>' . '<br/>' . $comment . '<br/>' . '<br/>' . '<hr size="1"/>'
;}
?>
</div>
<div id="content_right">
<form action="index.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="5" cols="50"></textarea></td> </tr>
<tr><td colspan="2"><input type="submit" name="submit" value="Comment"></td></tr>
</table>
</form>
</div>
</div>
<div id="footer">
<div id="footer_content">
Copyright © Maltese Law
</div>
</div>
</div>
</center>
</body>
</html>