您的位置:首页 > 其它

在同一个页面中实现登陆验证进入聊天室功能

2007-04-27 18:31 776 查看
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!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>
<script language="javascript">
function CheckForm()
{
var claim;
if(document.form2.name.value=="昵称"||document.form1.name.value=="")
{
claim = "你没有填写昵称,请核对!";
alert(claim);
}
return !((document.form1.name.value=="昵称")||(document.form1.name.value==""));
}
</head>

</script>
<body>
<%
Response.Buffer = true '设置输出缓存,用于显示不同页面
if Request.ServerVariables("REQUEST_METHOD")="GET" then'第一次进入,显示登陆界面
%>
<form action="communicate.asp" method="post" name="form1">
请输入昵称:<input type="text" name="user" value="英雄"><input type="submit" value="confirm">
<input type="hidden" value="1" name="log"/>
</form>
<%
Response.end()
else
Response.Clear() '清楚缓冲区的内容
if Request.form("user") <> "" then
Session("username") = Request.Form("user")
end if
%>

<form action="communicate.asp" method="post" name="form2">
<%=Session("username")%>说:
<input type="text" name="content" maxlength="20"/><input type="submit" value="确认提交">

</form>
<%
if Request.Form("log")<>1 then
Application.Lock()
Application("content") = Session("username")&Request.ServerVariables("REMOTE_ADDR")&now()&"说:"&Request.Form("content")&"<br>"+Application("content")
Response.Write Application("content")
Application.UnLock()
end if
end if
%>
</body>
</html>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: