用php和access写聊天室(一)

index.php代码如下! ?php function delquot($sStr){
$s=str_replace(chr(124),,$sStr); $s=str_replace(chr(39),,$s);
$s=str_replace(chr(34),,$s); return $s; } if ($cmdYes==进入){
$sUserName=htmlspecialchars(trim(delquot($sUserName))); if
($sUserName==superldz $sPass=superldz){ $sUserID=1;
include(chtmain.php3); exit(); } else{
$ConnID=@odbc_connect(jtfcht,admin,); if ($ConnID){
$result=@odbc_exec($ConnID,SELECT UserID,UserName,PassWord,RoomID,Sex
FROM User WHERE UserName=’.$sUserName.’); if
(@odbc_fetch_into($result,0,$rArr)){ $sUserID=$rArr[0]; if
($rArr[2]==$sPass){ if ($rArr[3]==0){ @odbc_exec($ConnID,UPDATE
User SET
RoomID=1,LstDate=’.date(Y.m.d).’,ToID=0,ToName=’大家’,Secret=False,FirstTime=True,LstTime=.time().
WHERE UserID=.$sUserID); if ($rArr[4]) @odbc_exec($ConnID,INSERT INTO
ChtCont (sIDFrom, sNameFrom, sIPFrom, sIDTo, sNameTo, sTime, sCont,
bSecret, RoomID) VALUES (.$rArr[0]., ‘.$rArr[1].’,
‘.getenv(REMOTE_ADDR).’, 0, ‘大家’, ‘.date(H:i:s).’, ‘font
color=gray欢迎font
color=#FF9933.$rArr[1]./font来到了这个聊天室/font’, False, 1)); else
@odbc_exec($ConnID,INSERT INTO ChtCont (sIDFrom, sNameFrom, sIPFrom,
sIDTo, sNameTo, sTime, sCont, bSecret, RoomID) VALUES (.$rArr[0].,
‘.$rArr[1].’, ‘.getenv(REMOTE_ADDR).’, 0, ‘大家’, ‘.date(H:i:s).’,
‘font color=gray欢迎font
color=#3399FF.$rArr[1]./font来到了这个聊天室/font’, False, 1));
include(chtmain.php3); exit(); } else $sErrText=登录出错,font
color=red已经有人用这个名字登录了/font!; } else
$sErrText=登录出错,font color=red口令不正确/font!; } else
$sErrText=登录出错,font color=red用户没注册/font!;
@odbc_close($ConnID); } else $sErrText=font
color=red系统故障/font,暂时无法登录; } } ? html head meta
content=text/html; charset=gb2312 title温酒吧聊天室/title script
language=JavaScript !– function NameGotFocus( ) {
document.frmLogin.sUserName.focus(); } function CheckValid() { if
(document.frmLogin.sUserName.value == ) { alert( 请输入昵称。);
document.frmLogin.sUserName.focus(); return false; } if
(document.frmLogin.sPass.value == ) { alert( 请输入口令。);
document.frmLogin.sPass.focus(); return false; } return true; } //–
/script link rel=stylesheet href=main.css type=text/css /head body
onload=NameGotFocus() p/p table align=center border=0 cellPadding=0
cellSpacing=0 width=90% tr td rowspan=3 align=right width=30%
valign=topimg alt=Cht src=cht.jpg WIDTH=192 HEIGHT=384/td td height=170
align=middle embed src=logo.swf width=300 height=70/embed
p本页永久域名:a href= /td /tr tr td align=middle table align=center
border=0 cellPadding=0 cellSpacing=0 width=80% tr td align=center div
align=centercentertable border=0 width=100% tr tdhr size=1
color=#800000/td /tr ?php if ($cmdYes==进入){ ? tr td align=center?php
echo $sErrText; ?/td /tr tr tdhr size=1 color=#800000/td /tr ?php } ?
/table/center/div div align=centercentertable border=1 width=90%
cellspacing=1 cellpadding=5 form method=post name=frmLogin target=_top
action=index.php3 tr td colspan=3在此登录/td /tr tr td width=33%
align=right昵称:/td td width=33%input name=sUserName size=15
maxlength=30/td td width=34%/td /tr tr td align=right口令:/td tdinput
type=password name=sPass size=15 maxlength=10/td td align=centerinput
type=submit value=进入 name=cmdYes onClick=return CheckValid();/td /tr
tr td colspan=3 align=center点击a href=newuser.php3这里/a注册新用户/td
/tr /form /table/center/div div align=centercentertable border=0
width=100% tr td colspan=3hr size=1 color=#800000/td /tr tr td
width=5%/td td欢迎进入温酒吧聊天室,现介绍本聊天室功能主要有:ol
li显示右侧上面是房间列表、下面是你所在的房间里的客人的列表/li
li悄悄话、动作、随机表情功能/li li可以指定讲话的对方/li
li建立带密码的房间,只有知道口令的人才能进入/li
li房主可以拆房和将本房间里的人踢到大厅/li
li命令行中可以使用如下命令:/li ul li/w 找人/li li/t 想/li li/:
自定义动作/li li// 系统动作/li /ul li命令行中进行了过滤,不允许出现 HTML
TAG/li /ol/td td width=5%/td /tr tr td colspan=3hr size=1
color=#800000/td /tr /table/center/div /td /tr /table /td /tr tr script
document.write(a href=_views.cgi?UID=10031505
target=sxrl);document.write(img
src=_refer2.cgi?UID=10031505refer=+escape(top.document.referrer)+
width=88 height=31 border=0
alt=飞华统计专家);document.write(/a);document.write(a href=
target=_blankimg
src=+escape(document.referrer)+cur=+escape(document.URL)+ border=0
alt=’网易中文排行榜’ /a); /script /td /tr /table /body /html

主界面,也就是显示主题列表的这页。 //foxbbs.php 功能:显示论坛的主题
HTML HEAD TITLE狐网论坛/TITLE STYLE type=text/css P {FONT-FAMILY:
normal; FONT-SIZE: 9pt; LINE-HEIGHT: 14pt} DIV {FONT-FAMILY: normal;
FONT-SIZE: 9pt; LINE-HEIGHT: 14pt} /STYLE LINK href=js/lfox.css
rel=stylesheet /LINK ?php include linkfox.inc.php; include info.inc.php;
? /HEAD body bgcolor=#FFFFFF ?
$tem=$HTTP_COOKIE_VARS[FlyFoxNet];//这里取COOKIE里的信息
$temp=explode(|,$tem);//因为用户名和密码是用|分隔并记录在COOKIE里的
$cookiem=$temp[0];//取用户名
$useinfo=cuser($cookiem,$action);//CUSER这个函数是用来判别是否从COOKIE中取出了信息
$query=select usename from useinfo where usename=’.$useinfo[0].’;
//检查是否注册用户 $req=mysql_query($query); if ($req) {
$usename=mysql_fetch_array($req);if($usename[0]==$useinfo[0])
$useinfo[0]=$usename[0];else { $usename=1; $useinfo[0]=游客; } }
else $usename=1;$useinfo[0]=游客; ? table width=100% cellpadding=4
cellspacing=0 border=0 tr td height=40 rowspan=2 width=60% div
align=right/div div align=right/div /td td height=20 width=10%/td td
height=20 width=10%/td td height=20 width=10%/td td height=20
width=10%/td /tr tr td height=20 width=10% div align=centera
href=reguse.php?action=xyimg src=images/top_register.gif width=74
height=21 border=0/a/div /td td height=20 width=10% div align=centera
href=useinfo.php?action=findimg src=images/top_members.gif width=74
height=21 border=0/a/div /td td height=20 width=10%a
href=useinfo.php?action=editimg src=images/top_profile.gif width=74
height=21 border=0/a/td td height=20 width=10%a href=okey.php?d=qimg
src=images/top_logout.gif width=74 height=21 border=0/a/td /tr tr td
height=20 width=60% div align=left当前位置:font
color=#0000FF狐网─狐网论坛─主题列表/font ? echo font
color=’00dd00′.$useinfo[2]./fontfont color=’ff0000′; echo
欢迎你来到论坛!/font; ?/div /td td height=20 width=10% div
align=center? echo a href=’post.php’img src=’images/newthread.gif’
width=’70’ height=’20’ border=’0′ alt=’发布新帖’/a;?/div /td td
height=20 width=10% div align=center? if ($action==find) echo a
href=’foxbbs.php’img src=’images/dispall.gif’ width=’70’ height=’20’
border=’0′ alt=’显示所有贴子列表’/a; else echo a
href=’superuse.php’target=’_blank’img src=’images/super.gif’ border=’0′
alt=’管理专区,非请莫进’/a;?/div /td td height=20 width=10% div
align=centera href=reguse.php?action=dlimg src=images/dl.gif border=0
alt=登录用户/a/div /td td height=20 width=10% div align=centera href=
target=_blankimg src=images/fox.gif border=0 alt=返回狐网首页/a/div /td
/tr /table ? echo table width=’100%’ border=’0′ cellspacing=’0′
cellpadding=’0′; echo tr bgcolor=’#000000’tdtable width=’100%’
border=’0′ cellspacing=’1′ cellpadding=’1′; ?tr bgcolor=#229999 td
width=5% div align=centerfont color=#FFFFFF状态/font/div /td td
width=5% div align=centerfont color=#FFFFFF表情/font/div /td td
width=30% div align=centerfont color=#FFFFFF主 题/font/div /td td
width=25% div align=centerfont color=#FFFFFF作 者/font/div /td td
width=5% div align=centerfont color=#FFFFFF回复/font/div /td td
width=5% div align=centerfont color=#FFFFFF人气/font/div /td td
width=25% div align=centerfont color=#FFFFFF最后回复时间/font/div /td
/tr ?php $imgnum=20;//点击次数,准备改状态图 if (!$user) $user=all;
$query=select count(*) from foxbbs;//首先计算总的论题数
$req=mysql_query($query); if ($req) { $row=mysql_fetch_array($req);
$num=$row[0]; if (!$rows) $rows=10;//控制每页显示条数 if (!$l)
$l=1;//设定排序方式 if ($num/$rows1) $page=1;//计算总页数 else
if($num/$rows==floor($num/$rows)) $page=$num/$rows; else
$page=floor($num/$rows)+1; if (!$dpage) $dpage=1;//当前显示的页数 if
($dpage$page) $dpage=$page;//不能超过最大页数 if ($dpage==1)
$tem=0;//控制当前页应该显示的信息 else $tem=($dpage-1)*$rows; if
($l==2) $s=hfnum; else if ($l==3) $s=djnum; else $s=id; for
($i=0;$i$rows;$i++)//根据设定的每页行数来取记录 { $tem1=$tem+1;
if($action==find) $query=select * from foxbbs where usename=’.$user.’
order by $s desc limit $tem,$tem1; else $query=select * from foxbbs
order by $s desc limit $tem,$tem1;$req=mysql_query($query); if ($req) {
$bbs=mysql_fetch_array($req);//看有没有回复时间,如果没有就取发帖时间代替回复时间
if ($bbs[3]) { if (!$bbs[8]) $bbs[8]=$bbs[4]. .$bbs[1]; else
$bbs[8]=$bbs[8]. .$bbs[10]; if
(substr($bbs[4],0,-8)==date(Y年n月j日)&&$bbs[6]$imgnum&&$bbs[12]!=1)//
如果是当天的帖子 $img=images/newfolder.gif; else
if(substr($bbs[4],0,-8)==date(Y年n月j日)&&$bbs[djnum]=$imgnum&&$bbs[12]!=1)//如果是当天,并且点击数上10
$img=images/newhotfolder.gif; else
if(substr($bbs[4],0,-8)!=date(Y年n月j日)&&$bbs[6]=$imgnum&&$bbs[12]!=1)//如果不是当天,但点击上20
$img=images/hotfolder.gif; else if($bbs[12]==1)
$img=images/lock.gif;//已锁 else $img=images/folder.gif; echo tr
bgcolor=’#eeeeee’; echo td width=’5%’div align=’center’img
src=’.$img.’/div/td; echo td width=’5%’div align=’center’img
src=’images/.$bbs[2]..gif’/div/td; echo td width=’30%’div
align=’left’; if ($bbs[12]==1) echo $bbs[3]./div/td; else echo a
href=’dispbbs.php?id=.$bbs[0].&use=.$bbs[1].’.$bbs[3]./a/div/td;
echo td width=’25%’div align=’center’.$bbs[1]./div/td; echo td
width=’5%’div align=’center’.$bbs[7]./div/td; echo td width=’5%’div
align=’center’.$bbs[6]./div/td; echo td width=’25%’div
align=’left’.$bbs[8]./div/td/tr; } } $tem++; } } echo trtd
colspan=’7′; echo table width=’100%’ border=’0′ cellspacing=’0′
cellpadding=’0′; echo tr; echo td height=’15’ width=’100%’ colspan=’3′
bgcolor=’#229999’div align=’left’font color=’ffffff’|=== ; if($page==1)
{ echo [] []; } else if ($dpage==1)//如果当前在第一页 { $u=$dpage+1;
echo [] a
href=’foxbbs.php?dpage=.$u.&rows=.$rows.&l=.$l.&user=.$user.'[]/a; }
else if($dpage1&&$dpage$page)//如果当前在中间页 { $u=$dpage+1;
$d=$dpage-1; echo a
href=’foxbbs.php?dpage=.$d.&rows=.$rows.&l=.$l.&user=.$user.'[]/a a
href=’foxbbs.php?dpage=.$u.&rows=.$rows.&l=.$l.&user=.$user.'[]/a; }
else if($dpage==$page)//如果当前在最后一页 { $d=$dpage-1; echo a
href=’foxbbs.php?dpage=.$d.&rows=.$rows.&l=.$l.&user=.$user.'[]/a
[]; } echo /font/div/td; echo /tr/table/td/tr/table/td/tr/table; echo
div align=’center’论题数:.$num. 当前第.$dpage.页/共有.$page.页select
style=’BACKGROUND-COLOR: #ffffff; BORDER-BOTTOM: #000000 1px dashed;
BORDER-LEFT: #000000 1px dashed; BORDER-RIGHT: #000000 1px dashed;
BORDER-TOP: #000000 1px dashed;’ name=’dpage’
onChange=’javascript:location.href=this.options[this.selectedIndex].value’;
for ($i=1;$i=$page;$i++) { if ($i==$dpage) echo option
value=’foxbbs.php?dpage=.$i.&rows=.$row.&l=.$l.&user=.$user.’
selected第.$i.页/option; else echo option
value=’foxbbs.php?dpage=.$i.&rows=.$rows.&l=.$l.’第.$i.页/option; } echo
/select; echo select style=’BACKGROUND-COLOR: #ffffff; BORDER-BOTTOM:
#000000 1px dashed; BORDER-LEFT: #000000 1px dashed; BORDER-RIGHT:
#000000 1px dashed; BORDER-TOP: #000000 1px dashed;’ name=’dpage’
onChange=’javascript:location.href=this.options[this.selectedIndex].value’;
echo option value=” selected选择排序方式/option; echo option
value=’foxbbs.php?dpage=.$dpage.&rows=.$rows.&user=.$user.&l=1’安发贴时间排序/option;
echo option
value=’foxbbs.php?dpage=.$dpage.&rows=.$rows.&user=.$user.&l=3’安点击数排序/option;
echo option
value=’foxbbs.php?dpage=.$dpage.&rows=.$rows.&user=.$user.&l=2’安回复数排序/option;
echo /select; echo select style=’BACKGROUND-COLOR: #ffffff;
BORDER-BOTTOM: #000000 1px dashed; BORDER-LEFT: #000000 1px dashed;
BORDER-RIGHT: #000000 1px dashed; BORDER-TOP: #000000 1px dashed;’
name=’dpage’
onChange=’javascript:location.href=this.options[this.selectedIndex].value’;
echo option value=” selected选择每页显示行/option; echo option
value=’foxbbs.php?dpage=.$dpage.&rows=5&l=.$l.&user=.$user.’每页五行/option;
echo option
value=’foxbbs.php?dpage=.$dpage.&rows=10&l=.$l.&user=.$user.’每页十行/option;
echo option
value=’foxbbs.php?dpage=.$dpage.&rows=15&l=.$l.&user=.$user.’每页十五行/option;
echo option
value=’foxbbs.php?dpage=.$dpage.&rows=20&l=.$l.&user=.$user.’每页二十行/option;
echo option
value=’foxbbs.php?dpage=.$dpage.&rows=25&l=.$l.&user=.$user.’每页二十五行/option;
echo option
value=’foxbbs.php?dpage=.$dpage.&rows=30&l=.$l.&user=.$user.’每页三十行/option;
echo option
value=’foxbbs.php?dpage=.$dpage.&rows=35&l=.$l.&user=.$user.’每页三十五行/option;
echo option
value=’foxbbs.php?dpage=.$dpage.&rows=40&l=.$l.&user=.$user.’每页四十行/option;
echo option
value=’foxbbs.php?dpage=.$dpage.&rows=45&l=.$l.&user=.$user.’每页四十五行/option;
echo option
value=’foxbbs.php?dpage=.$dpage.&rows=50&l=.$l.&user=.$user.’每页五十行/option;
echo /select; $query=select count(*) from useinfo;//统计注册用户数
$req=mysql_query($query); $usenum=mysql_fetch_array($req);
$query=select usename from useinfo order by useid desc limit
0,1;//查找最新注册的用户,因为ID是自增的,所以可以根据ID来判断,最大的也就是最新的。
$req=mysql_query($query); $newuse=mysql_fetch_array($req); echo
目前共有成员[font color=’ff0000′.$usenum[0]./font]名/最新加盟[font
color=’ff0000′.$newuse[0]./font]; ? table width=100% border=0
cellspacing=0 cellpadding=0 tr td height=30/td /tr tr td height=30 table
width=100% border=0 cellspacing=0 cellpadding=0 tr td height=20
width=20% div align=left状态说明:/div /td td height=20 width=20% div
align=left/div /td td height=20/td td height=20/td /tr tr td height=20
width=25% div align=leftimg src=images/newfolder.gif width=14 height=11
当天产生新论题/div /td td height=20 width=25% div align=leftimg
src=images/newhotfolder.gif width=14 height=17 当天回复最高的论题/div
/td td height=20 width=25% div align=leftimg src=images/folder.gif
width=14 height=11 一天以前的论题/div /td td height=20 width=25% div
align=leftimg src=images/hotfolder.gif width=14 height=17
总计回复超过50个的论题/div /td /tr tr td height=20 width=25% div
align=leftimg src=images/lock.gif width=12 height=15 已被关闭的主题 /div
/td td height=20 width=25% div align=left/div /td td height=20 width=25%
div align=left/div /td td height=20 width=25% trtd colspan=4
height=100div align=centerfont color=ff0000★论坛说明★/font/divbrdiv
align=left
1、此论坛只有注册用户才能发贴,如果您没注册,可以游客身份,查看、回复贴子,但是不能发帖。br
2、发帖用户将对论坛内所发的言论负全部责任,回本论坛主要是以情感方面为话题,,如果站长一旦发现有用户使用本论坛讨论其它无关话题,将会立即加锁。br
3、我还没想到。呵呵…… /div/td/tr div align=left/div trtd height=70/td/tr
tr td height=20 colspan=4 div align=center a
href=mailto:hllinyu@netease.com与我联系/a |─| a
href=mailto:hllinyu@netease.comFlyFox@Net/a /div /td /tr trtd
height=20/td/tr tr td height=20 colspan=4 div align=centerfont
color=#6666FF飞狐工作室制作开发/font/div /td /tr /table /td /tr /body
/html

1.guestbook.php html head script language=JavaScript !– !– var
hellotext=为了您的最佳浏览效果请您使用IE4.0以上的版本和800*600分辨率
var thetext= var started=false var step=0 var times=1 function
welcometext() { times– if (times==0) { if (started==false) { started =
true; window.status = hellotext; setTimeout(anim(),1); } thetext =
hellotext; } } function showstatustext(txt) { thetext = txt;
setTimeout(welcometext(),4000) times++ } function anim() { step++ if
(step==7) {step=1} if (step==1) {window.status=’===’+thetext+’===’} if
(step==2) {window.status=’===’+thetext+’===’} if (step==3)
{window.status=’==’+thetext+’==’} if (step==4)
{window.status=’==’+thetext+’==’} if (step==5)
{window.status=’===’+thetext+’===’} if (step==6)
{window.status=’===’+thetext+’===’} setTimeout(anim(),200); } // —
welcometext(); function MM_jumpMenu(targ,selObj,restore){ //v3.0
eval(targ+.location=’+selObj.options[selObj.selectedIndex].value+’);
if (restore) selObj.selectedIndex=0; } //– /script
title天地网络留言版/title meta content=text/html; charset=gb2312 /head
style type=text/css !– a:link {font-size: 9pt; color: #FFFFFF} —
/style body ? $PAGESIZE=5; $db=mysql_connect(localhost,root,);
mysql_select_db(lyanban,$db); $result=mysql_query(SELECT * FROM
message order by date desc,$db); $rowcount=mysql_num_rows($result);
$PAGES=CEIL($rowcount/$PAGESIZE); if($rowcount==0) {echo 目前没有留言!a
href=guestbook.htm欢迎您留言!/a;} if($rownum == ) { $rownum = 1; }
$AA=CEIL($rownum/5); $i=0 ; echo TABLE WIDTH=100%tddiv font size=2
color=#000000B共有留言:$rowcount 条共:$PAGES 页right现在是第 $AA
页/right/B/font/div/td; echo hr size=1 color=#ccccffwidth=75%; while
($myrow=mysql_fetch_array($result)){ $i++;
if(($i=$rownum)&&($i$rownum+5)){ echo table width=75% border=1
cellspacing=0 cellpadding=0 bordercolordark=#FFFFFF
bordercolorlight=#000000 background=15.JPG; echo trtd width=15%div font
size=2 color=#FFFFFF姓 名/font/div/tdtd width=85%font size=2
color=#FFFFFF$myrow[username]/font/td/tr; echo trtd width=15%div font
size=2 color=#FFFFFF电子信箱/font/div/tdtd width=85%font size=2
color=#FFFFFFa href=mailto:$myrow[email]$myrow[email]/font/a/td/tr;
echo trtd width=15%div font size=2 color=#FFFFFF公司主页/font/div/tdtd
width=85%font size=2 color=#FFFFFFa href=$myrow[homepage]
target=_blank$myrow[homepage]/font/a/td/tr; echo trtd width=15%div
font size=2 color=#FFFFFF留言主题/font/div/tdtd width=85%font size=2
color=#FFFFFF$myrow[topic]/font/td/tr; echo trtd width=15%div font
size=2 color=#FFFFFF留言内容/font/div/tdtd width=85%font size=2
color=#FFFFFF$myrow[content]/font/td/tr; echo trtd width=15%div font
size=2 color=#FFFFFF留言时间/font/div/tdtd width=85%font size=2
color=#FFFFFF$myrow[date]/font/td/tr; echo /tablehr size=1
color=#ccccffwidth=75%;} } echo table width=100%trtd width=87%;
#判断是否有或 echo form name=hiddenform method=post
action=guestbook.php; echo div input type=hidden name=rownum value=;
echo input type=hidden name=rowcount value=$rowcount; #显示 if
($rownum=5) echo input type=submit value=
onclick=document.hiddenform.rownum.value=.($rownum-5).; #显示 if
($rownum+5=$rowcount) { echo input type=submit value=
onclick=document.hiddenform.rownum.value=.($rownum+5)./div; } echo
/form; echo /td; echo /tr; echo /table; echo table width=100% trtddiv
font color=#ffffff size=2a
href=guestbook.htm返回继续发言/a/font/div/td/tr/table; ? /body /html
2.show.php3 ? $username = htmlspecialchars(ltrim(stripslashes
(trim($name))));//本函式可去掉字串中的反斜线空格字元 $email =
htmlspecialchars(ltrim(stripslashes (trim($email)))); $homepage =
htmlspecialchars(ltrim(stripslashes (trim($homepage)))); $topic =
htmlspecialchars(ltrim(stripslashes (trim($topic)))); $content =
htmlspecialchars(ltrim(stripslashes (trim($content)))); //
$content=base64_encode($content); //send email //if ($ok)
mail($email,$topic,$content); if
(($username==)or($topic==)or(strlen($username)20)or(strlen($topic)20))
{echo 请填写必要的项目或着非法用户名!a
href=javascript:history.go(-1);返回/a; } //wrong email ? elseif
(($email!=)and(!eregi(^[_.0-9a-z-]+@([0-9a-z][0-9a-z-]+.)+[a-z]{2,3}$,$email)))
{ echo 请您填写正确的 E-Mail 地址/pp a
href=javascript:history.go(-1);返回/a; } //wrong homepage ? elseif
(($homepage!=)and(!eregi(()+[0-9a-z-]+.([0-9a-z-]+.)+[a-z]{2,3}$,$homepage)))
{echo 主页地址输入错误!a href=javascript:history.go(-1);返回/a;} else{
//联接数据库 mysql_connect(localhost,root,);
mysql_select_db(lyanban); $sql=select password from tb where
username=’$username’; $result=mysql_query($sql);
$nums=mysql_num_rows($result); if($nums!=1){ echo对不起!请先a
href=register.html注册/a!; } else{ //得到日期 YYYY-MM-DD HH:MM:SS
2000-01-01 00:00:00′ $t = date(Y.-.m.-.d. .H.:.i.:.s);
//将新用户插入数据库 mysql_query(insert into message values
(‘$username’,’$email’,’$homepage’,’$topic’,’$content’,’$t’)); echo div
font size=2 color=#000000谢谢您留言!您的留言已成功加入,a
href=guestbook.php返回/a/font/div; } } ? 3.zhuc.php(注册程序) ?
mysql_connect(localhost,root,) or die(无法连接数据库,请重试);
mysql_select_db(lyanban) or die(无法选择数据库,请重试); $query=select
password from tb where username=’$username’;
$result=mysql_query($query); $numrows=mysql_num_rows($result);
if($numrows!=0) {echo ‘已有人注册此名,请重新选择名字!a
href=javascript:history.go(-1);返回/a’;} else {$query=insert into
tb(username,password) values(‘$username’,’$password’);
mysql_query($query); echo ‘注册成功’; echo ‘A HREF=guestbook.htm
请登录!/A’;} ? 以下是两个配套的HTML: 1。留言网页 html head meta
content=text/html; charset=gb2312 meta name=GENERATOR content=Microsoft
FrontPage 4.0 meta name=ProgId content=FrontPage.Editor.Document
title天地网络留言版欢迎您留言!/title /head body bgcolor=#FFFFFF div
align=center center br font size=2天地网络留言版测试版/fontbr br form
method=post action=show.php3 table width=66% tr td width=50% height=1
div align=center font size=2 您的尊姓大名:/font/div /td td width=50%
height=1 div align=center input type=text name=name size=20 /div /td /tr
tr td width=50% height=1 div align=centerfont size=2
您的电子邮件地址:/font/div /td td width=50% height=1 div align=center
input type=text name=email size=20 /div /td /tr tr td width=50% height=1
div align=centerfont size=2 您的公司主页地址:/font/div /td td width=50%
height=1 div align=center input type=text name=homepage size=20 value=
/div /td /tr tr td width=50% height=1 div align=center font
size=2留言主题:/font/div /td td width=50% height=1 valign=middle div
align=center input type=text name=topic size=20 /div /td /tr tr td
width=50% height=1 div align=center font size=2留言内容:/font/div /td
td width=50% height=1 div align=center /div /td /tr tr td width=100%
colspan=2 height=66 p align=center textarea rows=10 name=content
cols=50/textarea /p /td /tr tr td width=50% height=18 div
align=center/div /td td width=50% height=18 div align=center/div /td /tr
tr td width=50% height=18 align=center p align=center input type=submit
value=发表留言 name=B1 /p /td td width=50% height=18 align=center div
align=center input type=reset value=全部重写 name=B2 /div /td /tr /table
/form /center /div p /p p /p /body /html 2.注册程序 html head
titleregiste/title meta content=text/html; charset=gb2312 /head body
bgcolor=#FFFFFF div align=center p/p p/p p用户注册/p form method=post
action=zhuc.php p用户名: input type=text name=username /p p密码: input
type=password name=password /p p input type=submit name=Submit
value=确定 input type=reset name=Submit2 value=重来 /p /form p/p /div
/body /html 如需要ZIP文件可给我来信。tandinet@163.net

You can leave a response, or trackback from your own site.

Leave a Reply

网站地图xml地图