我为一个有 3 个不同 php 页面的网站创建了一个留言簿,在有人对留言簿提交评论后,我无法查看文本.. 这是每个的编码
留言簿.php
<style type="text/css">
body,td,th {
color: #FFFFFF;
}
body {
background-color: #333333;
}
a:link {
color: #FFFFFF;
}
a:visited {
color: #FFFFFF;
}
a:hover {
color: #FFFFFF;
}
a:active {
color: #FFFFFF;
}
</style>
<body bgcolor="#333333" text="#FFFFFF" link="#FFFFFF" vlink="#FFFFFF" alink="#FFFFFF"> <table width="400" border="0" align="center" cellpadding="3" cellspacing="0">
<tr>
<td> </td>
</tr>
</table>
<table width="400" border="0" align="center" cellpadding="0" cellspacing="1" >
<tr>
<form id="form1" name="form1" method="post" action="addguestbook.php">
<td>
<table width="400" border="0" cellpadding="3" cellspacing="1" >
<tr>
<td width="117">Name</td>
<td width="14">:</td>
<td width="357"><input name="name" type="text" id="name" size="40" /></td>
</tr>
<tr>
<td>Email</td>
<td>:</td>
<td><input name="email" type="text" id="email" size="40" /></td>
</tr>
<tr>
<td valign="top">Comment</td>
<td valign="top">:</td>
<td><textarea name="comment" cols="40" rows="3" id="comment"></textarea></td>
</tr>
<tr>
<td> </td>
<td> </td>
<td><input type="submit" name="Submit" value=" Sign " /> <input type="reset" name="Submit2" value="Reset" /></td>
</tr>
</table>
</td>
</form>
</tr>
</table>
<table width="400" border="0" align="center" cellpadding="3" cellspacing="0">
<tr>
<td> </td>
</tr>
</table>
地址簿.php
<style type="text/css">
body,td,th {
color: #FFF;
}
body {
background-color: #333333;
}
a:link {
color: #FFF;
}
a:visited {
color: #FFF;
}
a:hover {
color: #FFF;
}
a:active {
color: #FFF;
}
</style>
<body bgcolor="#333333" text="#FFF" link="#FFF" vlink="#FFF" alink="#FFF"><?php
$host="*********"; // Host name
$username="***********"; // Mysql username
$password="***********!"; // Mysql password
$db_name="***********"; // Database name
$tbl_name="guestbook"; // Table name
// Connect to server and select database.
mysql_connect("$host", "$username", "$password")or die("cannot connect server ");
mysql_select_db("$db_name")or die("cannot select DB");
$datetime=date("y-m-d h:i:s"); //date time
$sql="INSERT INTO $tbl_name(name, email, comment, datetime)VALUES('$name', '$email', '$comment', '$datetime')";
$result=mysql_query($sql);
//check if query successful
if($result){
echo "Successful";
echo "<BR>";
}
else {
echo "ERROR";
}
mysql_close();
?>
访客留言簿.php
<?php
$host="*********"; // Host name
$username="******"; // Mysql username
$password="*****!"; // Mysql password
$db_name="******"; // Database name
$tbl_name="guestbook"; // Table name
// Connect to server and select database.
mysql_connect("$host", "$username", "$password")or die("cannot connect server ");
mysql_select_db("$db_name")or die("cannot select DB");
$sql="SELECT * FROM $tbl_name";
$result=mysql_query($sql);
while($rows=mysql_fetch_array($result)){
?>
<style type="text/css">
body,td,th {
color: #FFF;
}
body {
background-color: #666;
}
a:link {
color: #FFF;
}
a:visited {
color: #FFF;
}
a:hover {
color: #fff;
}
a:active {
color: #FFF;
}
</style>
<table width="400" border="1" align="center" cellpadding="0" cellspacing="1" >
<tr>
<td><table width="400" border="0" cellpadding="3" cellspacing="1" >
<tr>
<td width="117">Name</td>
<td width="14">:</td>
<td width="357"><? echo $rows['name']; ?></td>
</tr>
<tr>
<td valign="top">Comment</td>
<td valign="top">:</td>
<td><? echo $rows['comment']; ?></td>
</tr>
<tr>
<td valign="top">Date/Time </td>
<td valign="top">:</td>
<td><? echo $rows['datetime']; ?></td>
</tr>
</table></td>
</tr>
</table>
<p>
<?php
}
mysql_close(); //close database
?>
</p>
<p> </p>
如果有人可以帮忙吗?另外我评论的顺序显示升序我想显示他们降序?