ASP程序练习题目
发布网友
发布时间:2023-03-24 22:45
我来回答
共1个回答
热心网友
时间:2023-12-11 06:03
页面1.asp
<%
'接收表单数据
dim Action,user,password
Action=request.querystring("action")
user=Request.Form(user)
password=Request.Form(password)
If Action =login Then
if user=" " or password=" " then
response.write "密码或用户名不能为空!"
else
Session("user")=user
session("password")=password
response.Redirect (2.asp)
end if
end if
'表单部分
<form method='POST' action='1.asp?action=login' name='form'>
<input type='text' name='user' size=30 /><br>
<input type='text' name='password' size=30 /><br>
<input type='submit' value='登录' />
</form>
%>
页面2.asp
<%
if Session("user")<>"" and session("password")<>"" then
response.write Session("user")& "欢迎你的到来!"
else
response.Redirect (1.asp)
end if
%>
5-5.asp:
<html>
<body>
<h2 align="center">我的主页</h2>
<%
if Session("intVisit")<>"" then
Application.Lock
Application("intAll")=Application("intAll")+1
Application.UnLock
Session("intVisit")=0
end if
Dim intVisit
intVisit=Application("intAll")
Response.Write"<p>您是第"&intVisit&"位访客。"
%>
</body>
</html>
聊天室代码chat.asp
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<%
If Session("name")="" Then
Response.Redirect("welcome.asp")
%>
<% End If %>
<%
If Request.Form("say") <>"" Then
'过滤特殊字符
say = Replace(say ,"<p>","")
say = Replace(say ,"<br>","")
Application("chat")=Session("name") & "说:" & Request.Form("say") & "<br>" &"用户IP:"&Session("userip")&"发言时间:"&now()& "<br><br>" &Application("chat")
%>
<% End If %>
<!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">
<!--
.STYLE1 {color: #FF0000}
-->
</style>
</head>
<body>
<form id="form1" name="form1" method="post" action="chat.asp">
<table width="400" border="1">
<tr>
<td width="80"><div align="center"><span class="STYLE1"><%= Session("name") %></span></div></td>
<td><label>
<input name="say" type="text" id="say" />
</label></td>
<td><label>
<input type="submit" name="Submit" value="发 言" />
</label></td>
</tr>
</table>
</form>
<p><%= Application("chat") %></p><br>
</body>
</html>
页面welcome.asp
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<%
If Request.Form("name")<>"" Then
Session("name")=Request.Form("name")
Session("userip")=Request.ServerVariables("REMOTE_ADDR")
Response.Redirect("chat.asp")
%>
<% End If %>
<!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">
<!--
.STYLE1 {
font-size: 24px;
color: #FF0000;
}
-->
</style>
</head>
<body>
<p>欢迎到<span class="STYLE1">品网情缘</span>聊天室</p>
<form id="form1" name="form1" method="post" action="welcome.asp">
<table width="400" border="1">
<tr>
<td width="60"><div align="center">呢 称:</div></td>
<td width="200"><label>
<input name="name" type="text" id="name" size="20" />
</label></td>
<td width="118"><label>
<input type="submit" name="Submit" value="进 入" />
</label></td>
</tr>
</table>
</form>
<p> </p>
</body>
</html>