今天做的php留言本
--
-- 表的结构 `book`
--
CREATE TABLE `book` (
`id` int(8) NOT NULL auto_increment,
`username` varchar(50) default NULL,
`qq` varchar(50) default NULL,
`email` varchar(50) default NULL,
`title` varchar(50) default NULL,
`content` text,
`time` varchar(50) default NULL,
`retime` varchar(50) default NULL,
`recon` text,
PRIMARY KEY (`id`)
) TYPE=MyISAM AUTO_INCREMENT=1 ;
--
-- 导出表中的数据 `book`
--
-- --------------------------------------------------------
--
-- 表的结构 `users`
--
CREATE TABLE `users` (
`id` int(8) NOT NULL auto_increment,
`username` varchar(50) default NULL,
`userid` varchar(50) default NULL,
`password` varchar(50) default NULL,
`email` varchar(50) default NULL,
PRIMARY KEY (`id`)
) TYPE=MyISAM AUTO_INCREMENT=2 ;
--
-- 导出表中的数据 `users`
--
上面的是sql
添加记录add.php
[/code]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>添加留言</title>
<style type="text/css">
<!--
body,td,th {
font-size: 12px;
color: #333333;
font-family: 宋体;
}
a {
font-size: 12px;
color: #333333;
font-family: 宋体;
}
a:link {
text-decoration: none;
}
a:visited {
text-decoration: none;
color: #333333;
}
a:hover {
text-decoration: none;
color: #FF0000;
}
a:active {
text-decoration: none;
color: #0000FF;
}
body {
margin-left: 0px;
margin-top: 20px;
margin-right: 0px;
margin-bottom: 0px;
}
.input1 {
height: 20px;
width: auto;
border-top-width: 1px;
border-right-width: 1px;
border-bottom-width: 1px;
border-left-width: 1px;
border-top-style: solid;
border-right-style: solid;
border-bottom-style: solid;
border-left-style: solid;
border-top-color: #666666;
border-right-color: #CECFCE;
border-bottom-color: #CECFCE;
border-left-color: #636563;
}
.con {
height: auto;
width: auto;
border-top-width: 1px;
border-right-width: 1px;
border-bottom-width: 1px;
border-left-width: 1px;
border-top-style: solid;
border-right-style: solid;
border-bottom-style: solid;
border-left-style: solid;
border-top-color: #666666;
border-right-color: #CECFCE;
border-bottom-color: #CECFCE;
border-left-color: #636563;
overflow: auto;
}
.red {
color: #FF0000;
}
-->
</style>
</head>
<body>
<?
if($username!="")
{
$ID = uniqid("bookID");
$db = mysql_connect("localhost","root","");
mysql_select_db ("wpsni");
$add_time=date("Y")."-".date("m")."-".date("d")." ".date("H").":".date("i").":".date("s");
$result = mysql_query ("insert into book (id, username,email , qq, title,content,time)
VALUES ('$ID', '$username', '$email', '$qq','$title','$content','$add_time')");
if(!$result)
{
echo "<center>出现错误:</center>", mysql_error();
exit;
}
if($result)
{
mysql_close($db);
echo "<center>用户 <b>$username</b> 留言成功!</center>";
}
}
else
{
echo "<center>资料填写不完整,请仔细填写!</center>";
?>
<table width="415" height="297" border="0" align="center" cellpadding="0" cellspacing="0" background="images/add_bg.gif">
<tr>
<td height="35" colspan="2" align="center" valign="top"><img src="images/add_top.gif" width="489" height="35" /></td>
</tr>
<tr>
<td height="232" colspan="2"><form id="form1" name="form1" method="post" action="add.php">
<table width="424" height="142" border="0" align="center" cellpadding="3" cellspacing="1" bgcolor="#EBEBEB">
<tr>
<td width="42" bgcolor="#FFFFFF">名 字</td>
<td width="359" height="25" bgcolor="#FFFFFF"><label>
<input name="username" type="text" class="input1" id="username" size="20" />
<span class="red"> * </span></label></td>
</tr>
<tr>
<td height="26" bgcolor="#FFFFFF">Q Q</td>
<td height="25" bgcolor="#FFFFFF"><label>
<input name="qq" type="text" class="input1" id="qq" size="10" />
</label></td>
</tr>
<tr>
<td bgcolor="#FFFFFF">Email</td>
<td height="25" bgcolor="#FFFFFF"><label>
<input name="email" type="text" class="input1" id="email" size="20" />
</label></td>
</tr>
<tr>
<td bgcolor="#FFFFFF">标 题</td>
<td height="25" bgcolor="#FFFFFF"><label>
<input name="title" type="text" class="input1" id="title" size="30" />
<span class="red">* </span></label></td>
</tr>
<tr>
<td bgcolor="#FFFFFF">内 容</td>
<td bgcolor="#FFFFFF"><label>
<textarea name="content" cols="45" rows="8" class="con" id="content"></textarea>
<span class="red">* </span></label></td>
</tr>
<tr>
<td colspan="2" bgcolor="#FFFFFF"><div align="center">
<label>
<input type="submit" name="Submit" value="提交" />
</label>
<label>
<input type="reset" name="Submit2" value="重置" />
</label>
</div></td>
</tr>
</table>
</form>
</td>
</tr>
<tr>
<td height="30" colspan="2" align="center" valign="bottom"><img src="images/add_end.gif" width="489" height="30" /></td>
</tr>
</table>
<?
}
?>
</body>
</html>
[/code]
显示index.php
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<style type="text/css">
<!--
input { font-size:9pt;}
A:link {text-decoration: underline; font-size:9pt;color:000059}
A:visited {text-decoration: underline; font-size:9pt;color:000059}
A:active {text-decoration: none; font-size:9pt}
A:hover {text-decoration:underline;color:red}
body,table {font-size: 9pt}
tr,td{font-size:9pt}
-->
</style>
<title>注册会员列表 - 读取mysql的测试</title>
</HEAD>
<?
//连接到本地mysql数据库
$myconn=mysql_connect("localhost","root","");
//选择test为操作库
mysql_select_db("wpsni",$myconn);
$strSql="select * from book";
//用mysql_query函数从book表里读取数据
$result=mysql_query($strSql,$myconn);
while($row=mysql_fetch_array($result))//通过循环读取数据内容
{
?>
<table width="356" height="166" border="0" align="center" cellpadding="2" cellspacing="1" bgcolor="#FFFFFF">
<tr>
<td width="42" bgcolor="#CACACA"><samp>姓名</samp></td>
<td width="300" bgcolor="#E4E4E4"><?echo $row["username"]?></td>
</tr>
<tr>
<td bgcolor="#CACACA">QQ</td>
<td bgcolor="#E4E4E4"><?echo $row["qq"]?></td>
</tr>
<tr>
<td bgcolor="#CACACA">email</td>
<td bgcolor="#E4E4E4"><?echo $row["email"]?></td>
</tr>
<tr>
<td bgcolor="#CACACA">标题</td>
<td bgcolor="#E4E4E4"><?echo $row["title"]?></td>
</tr>
<tr>
<td bgcolor="#CACACA">内容</td>
<td bgcolor="#E4E4E4"><?echo $row["content"]?></td>
</tr>
<tr>
<td bgcolor="#CACACA">时间</td>
<td bgcolor="#E4E4E4"><?echo $row["time"]?></td>
</tr>
</table>
<br>
<?
}
//关闭对数据库的连接
mysql_close($myconn);
?>
</BODY>
</HTML>
-- 表的结构 `book`
--
CREATE TABLE `book` (
`id` int(8) NOT NULL auto_increment,
`username` varchar(50) default NULL,
`qq` varchar(50) default NULL,
`email` varchar(50) default NULL,
`title` varchar(50) default NULL,
`content` text,
`time` varchar(50) default NULL,
`retime` varchar(50) default NULL,
`recon` text,
PRIMARY KEY (`id`)
) TYPE=MyISAM AUTO_INCREMENT=1 ;
--
-- 导出表中的数据 `book`
--
-- --------------------------------------------------------
--
-- 表的结构 `users`
--
CREATE TABLE `users` (
`id` int(8) NOT NULL auto_increment,
`username` varchar(50) default NULL,
`userid` varchar(50) default NULL,
`password` varchar(50) default NULL,
`email` varchar(50) default NULL,
PRIMARY KEY (`id`)
) TYPE=MyISAM AUTO_INCREMENT=2 ;
--
-- 导出表中的数据 `users`
--
上面的是sql
添加记录add.php
[/code]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>添加留言</title>
<style type="text/css">
<!--
body,td,th {
font-size: 12px;
color: #333333;
font-family: 宋体;
}
a {
font-size: 12px;
color: #333333;
font-family: 宋体;
}
a:link {
text-decoration: none;
}
a:visited {
text-decoration: none;
color: #333333;
}
a:hover {
text-decoration: none;
color: #FF0000;
}
a:active {
text-decoration: none;
color: #0000FF;
}
body {
margin-left: 0px;
margin-top: 20px;
margin-right: 0px;
margin-bottom: 0px;
}
.input1 {
height: 20px;
width: auto;
border-top-width: 1px;
border-right-width: 1px;
border-bottom-width: 1px;
border-left-width: 1px;
border-top-style: solid;
border-right-style: solid;
border-bottom-style: solid;
border-left-style: solid;
border-top-color: #666666;
border-right-color: #CECFCE;
border-bottom-color: #CECFCE;
border-left-color: #636563;
}
.con {
height: auto;
width: auto;
border-top-width: 1px;
border-right-width: 1px;
border-bottom-width: 1px;
border-left-width: 1px;
border-top-style: solid;
border-right-style: solid;
border-bottom-style: solid;
border-left-style: solid;
border-top-color: #666666;
border-right-color: #CECFCE;
border-bottom-color: #CECFCE;
border-left-color: #636563;
overflow: auto;
}
.red {
color: #FF0000;
}
-->
</style>
</head>
<body>
<?
if($username!="")
{
$ID = uniqid("bookID");
$db = mysql_connect("localhost","root","");
mysql_select_db ("wpsni");
$add_time=date("Y")."-".date("m")."-".date("d")." ".date("H").":".date("i").":".date("s");
$result = mysql_query ("insert into book (id, username,email , qq, title,content,time)
VALUES ('$ID', '$username', '$email', '$qq','$title','$content','$add_time')");
if(!$result)
{
echo "<center>出现错误:</center>", mysql_error();
exit;
}
if($result)
{
mysql_close($db);
echo "<center>用户 <b>$username</b> 留言成功!</center>";
}
}
else
{
echo "<center>资料填写不完整,请仔细填写!</center>";
?>
<table width="415" height="297" border="0" align="center" cellpadding="0" cellspacing="0" background="images/add_bg.gif">
<tr>
<td height="35" colspan="2" align="center" valign="top"><img src="images/add_top.gif" width="489" height="35" /></td>
</tr>
<tr>
<td height="232" colspan="2"><form id="form1" name="form1" method="post" action="add.php">
<table width="424" height="142" border="0" align="center" cellpadding="3" cellspacing="1" bgcolor="#EBEBEB">
<tr>
<td width="42" bgcolor="#FFFFFF">名 字</td>
<td width="359" height="25" bgcolor="#FFFFFF"><label>
<input name="username" type="text" class="input1" id="username" size="20" />
<span class="red"> * </span></label></td>
</tr>
<tr>
<td height="26" bgcolor="#FFFFFF">Q Q</td>
<td height="25" bgcolor="#FFFFFF"><label>
<input name="qq" type="text" class="input1" id="qq" size="10" />
</label></td>
</tr>
<tr>
<td bgcolor="#FFFFFF">Email</td>
<td height="25" bgcolor="#FFFFFF"><label>
<input name="email" type="text" class="input1" id="email" size="20" />
</label></td>
</tr>
<tr>
<td bgcolor="#FFFFFF">标 题</td>
<td height="25" bgcolor="#FFFFFF"><label>
<input name="title" type="text" class="input1" id="title" size="30" />
<span class="red">* </span></label></td>
</tr>
<tr>
<td bgcolor="#FFFFFF">内 容</td>
<td bgcolor="#FFFFFF"><label>
<textarea name="content" cols="45" rows="8" class="con" id="content"></textarea>
<span class="red">* </span></label></td>
</tr>
<tr>
<td colspan="2" bgcolor="#FFFFFF"><div align="center">
<label>
<input type="submit" name="Submit" value="提交" />
</label>
<label>
<input type="reset" name="Submit2" value="重置" />
</label>
</div></td>
</tr>
</table>
</form>
</td>
</tr>
<tr>
<td height="30" colspan="2" align="center" valign="bottom"><img src="images/add_end.gif" width="489" height="30" /></td>
</tr>
</table>
<?
}
?>
</body>
</html>
[/code]
显示index.php
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<style type="text/css">
<!--
input { font-size:9pt;}
A:link {text-decoration: underline; font-size:9pt;color:000059}
A:visited {text-decoration: underline; font-size:9pt;color:000059}
A:active {text-decoration: none; font-size:9pt}
A:hover {text-decoration:underline;color:red}
body,table {font-size: 9pt}
tr,td{font-size:9pt}
-->
</style>
<title>注册会员列表 - 读取mysql的测试</title>
</HEAD>
<?
//连接到本地mysql数据库
$myconn=mysql_connect("localhost","root","");
//选择test为操作库
mysql_select_db("wpsni",$myconn);
$strSql="select * from book";
//用mysql_query函数从book表里读取数据
$result=mysql_query($strSql,$myconn);
while($row=mysql_fetch_array($result))//通过循环读取数据内容
{
?>
<table width="356" height="166" border="0" align="center" cellpadding="2" cellspacing="1" bgcolor="#FFFFFF">
<tr>
<td width="42" bgcolor="#CACACA"><samp>姓名</samp></td>
<td width="300" bgcolor="#E4E4E4"><?echo $row["username"]?></td>
</tr>
<tr>
<td bgcolor="#CACACA">QQ</td>
<td bgcolor="#E4E4E4"><?echo $row["qq"]?></td>
</tr>
<tr>
<td bgcolor="#CACACA">email</td>
<td bgcolor="#E4E4E4"><?echo $row["email"]?></td>
</tr>
<tr>
<td bgcolor="#CACACA">标题</td>
<td bgcolor="#E4E4E4"><?echo $row["title"]?></td>
</tr>
<tr>
<td bgcolor="#CACACA">内容</td>
<td bgcolor="#E4E4E4"><?echo $row["content"]?></td>
</tr>
<tr>
<td bgcolor="#CACACA">时间</td>
<td bgcolor="#E4E4E4"><?echo $row["time"]?></td>
</tr>
</table>
<br>
<?
}
//关闭对数据库的连接
mysql_close($myconn);
?>
</BODY>
</HTML>
煮什么汤能除尘呢?
PHP分页原理是怎么样的
