|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
左手拿着MOTOLOLA右手拿着NOKIA,要多潇洒,有多潇洒,哈哈,终于学会了,但是可能这个时候,又会有人不经意的拍拍肩膀对你说:哥们,别高兴的太早,你还是菜鸟,离学会还差着一大截呢! guestbook.php:
<head>
<meta http-equiv="Content-Language" content="zh-cn">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title></title>
<STYLE>A:link {
COLOR: #002878; TEXT-DECORATION: none
}
A:visited {
COLOR: #002878; TEXT-DECORATION: none
}
A:active {
TEXT-DECORATION: none
}
A:hover {
COLOR: #cc1111; TEXT-DECORATION: none
}
P {
COLOR: #002878; FONT-SIZE: 9pt
}
TABLE {
COLOR: #002878; FONT-SIZE: 9pt
}
LI {
COLOR: #002878; FONT-SIZE: 9pt; LINE-HEIGHT: 14pt
}
UL {
COLOR: #002878; FONT-SIZE: 9pt
}
}
</STYLE>
</head>
<body>
<div align="center">
<center>
<table border="0" cellpadding="0" cellspacing="0" width="574" height="312">
</center>
<tr>
<td><p align="center">高三<6>班留言本本</br></td>
</tr>
<tr>
<td width="574" height="272" valign="top">
<form method="POST" action="ly.php">
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<center>
<tr>
<td width="26%" align="right">
姓名:</td>
<td width="74%"><input style="font-size: 9pt; width: 186; background-color: #f8f8f8; height: 19; border: 1px solid #9a9999"
type="text" name="T1" size="13"></td>
</tr>
<tr>
<td width="26%" align="right">
EMAIL:</td>
<td width="74%"><input style="font-size: 9pt; width: 186; background-color: #f8f8f8; height: 19; border: 1px solid #9a9999" name="T2" size="13"></td>
</tr>
<tr>
<td width="26%" align="right">
团体主页:</td>
<td width="74%"><input style="font-size: 9pt; width: 186; background-color: #f8f8f8; height: 19; border: 1px solid #9a9999" name="T3" size="13" value="http://"></td>
</tr>
<tr>
<td width="26%" align="right">
主题:</td>
<td width="74%"><input style="font-size: 9pt; width: 186; background-color: #f8f8f8; height: 19; border: 1px solid #9a9999" name="T4" size="13"></td>
</tr>
<tr>
<td width="26%" align="right" valign="top">
留言:</td>
<td width="74%"><textarea style="font-size: 9pt; width: 313; background-color: #f8f8f8; height: 177; border: 1px solid #9a9999" rows="10" name="S1" cols="45" ></textarea></td>
</tr>
<tr>
<td width="100%" align="right" colspan="2">
</td>
</tr>
</table>
<p align="center">
<input type="submit" value="提交" name="B1"> <input type="reset" value="重写" name="B2"></p>
</form>
</center>
</td>
</tr>
</table>
<hr size='1' color='#6666FF'>
</div>
<div align="center">
<center>
<table border="0" cellpadding="0" cellspacing="0" width="603" height="294">
<tr>
<td width="603" height="294">
<?
include ("connect.rec");
$qh=mysql_query("SELECT COUNT(*) AS rcnt FROM guestbook");
$data=mysql_fetch_array($qh);
$nr=$data["rcnt"];
//判别偏移量参数是不是传递给了剧本,假如没有就利用默许值0
if (empty($offset))
{
$offset=0;
}
//查询了局(这里是每页20条,但你本人完整可以改动它)
//$result=mysql_query("SELECT * from guestbook ORDER BY time desc LIMIT $offset, 5");
$result=mysql_query("SELECT * from guestbook LIMIT $offset, 5");
//显示前往的5笔记录
while ($data=mysql_fetch_array($result))
{
printf("姓名:<font color='#000000'>%s</font><br>",$data["name"]);
printf("EMAIL:<font color='#3366FF'>%s</font><br>",$data["mail"]);
printf("团体主页:<font color='#3366FF'>%s</font><br>",$data["url"]);
printf("来自:<font color='#3366FF'>%s</font><br>",$data["ip"]);
printf("留言工夫:<font color='#3366FF'>%s</font><br>",$data["time"]);
printf("主题:<font color='#3366FF'>%s</font><br>",$data["title"]);
printf("内容:<font color='#000000'>%s</font><br>",$data["ly"]);
printf("<hr size='1' color='#6666FF'>");
}
//下一步,要写出到其它页面的链接
if($offset) //假如偏移量是0,不显示前一页的链接
{
$preoffset=$offset-5;
print "<a href="$PHP_SELF?offset=$preoffset">前一页</a> n";
}
//盘算总共需求的页数
$pages=ceil($nr/5); //$pages变量如今包括所需的页数
for ($i=1; $i <= $pages; $i++)
{
$newoffset=5*$i-5;
print "<a href="$PHP_SELF?offset=$newoffset">$i</a> n";
}
//反省是不是是最初一页
$next = $offset+5;
if ($next<$nr)
{
print "<a href="$PHP_SELF?offset=$next">下一页</a> n";
}
printf("<a href='javascript:history.back()'>前往</a>")
?>
</td>
</tr>
</table>
</center>
</div>
</body>
</html>
ly.php:
<?
include ("connect.rec");
$name = $T1;
$mail = $T2;
$url = $T3;
$title = $T4;
$time = date( "Y-m-j H:i:s" );
$ip = getenv("REMOTE_ADDR");
$ly = $S1;
$result = mysql_query("insert into guestbook (name,mail,url,ip,time,title,ly) values ('$name','$mail','$url','$ip','$time','$title','$ly')");
if ($result == 1)
{
echo("留言胜利!");
printf("<script language='javascript'>");
printf("location='guestbook.php'");
printf("</script>");
}
else
{
echo("留言掉败!");
printf("<a href='javascript:history.back()'>前往</a>");
}
?>
可到http://xinai.oso.com.cn/class/guesttap.php检查
从刚开始练习的PHP基础语法练习,到PHP语言在WEB中的应用,再到实际的项目开发,如留言版,相册系统,中小型公司网站系统,以及期间做过的有关团队合作的小游戏,让我受益匪浅,学到了很多。 |
|