WEB开发网
开发学院WEB开发ASP ASP入门基础教程-实例 网上图书管理系统 阅读

ASP入门基础教程-实例 网上图书管理系统

 2006-10-27 12:01:46 来源:WEB开发网   
核心提示: 1、通过表单提交用户所填资料;2、按一定的规则自动生成会员ID;3、通过myreset()自定义函数执行重写命令;4、通过mysubmit()自定义函数检查资料是否填写完整,如不完整,ASP入门基础教程-实例 网上图书管理系统(9),弹出相应的提示框,否则进行表单提交,此函数就显示相应的提

1、通过表单提交用户所填资料;

2、按一定的规则自动生成会员ID;

3、通过myreset()自定义函数执行重写命令;

4、通过mysubmit()自定义函数检查资料是否填写完整,如不完整,弹出相应的提示框,否则进行表单提交,进入本页面的程序处理代码,处理完毕,跳转到"register_OK.asp"页面,显示注册成功相关信息。

<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file="Connections/conn.asp" -->
<%
'如果从表单中提取的用户名不为空,而且session("mName")为空,则,
if Request.Form("mName")<>"" and session("mName")="" then
'将表单中获取的ID、用户名和密码分别存入变量session("MyID")、session("mName")和session("MyPD")中。
session("MyID")=request.Form("ID")
session("mName")=Request.Form("mName")
session("MyPWD")=request.Form("PassWord")
'将从表单中提取来的各项值分别存入相应的变量中。
mName=Request.Form("mName")
city=Request.Form("city")
address=Request.Form("address")
postcode=Request.Form("postcode")
CardNO=Request.Form("CardNO")
CardType=Request.Form("CardType")
Tel=Request.Form("Tel")
Email=Request.Form("Email")
'向DB_Member表中插入一条记录,各字段值就是从表单中提取来的各项值。
Ins_sql = "Insert into DB_Member (ID,mName,PassWord,city,address,postcode,CardNO,"&_
"CardType,Tel,Email) values('"&session("MyID")&"','"&mName&"','"&session("MyPWD")&_
"','"&city&"','"&address&"','"&postcode&"','"&CardNO&"','"&CardType&"','"&Tel&_
"','"&Email&"')"
conn.execute(Ins_sql)
'页面转向到“register_OK.asp”页面。即注册成功页面。
response.redirect("register_OK.asp")
end if
%>
<%
'创建一个记录集对象。
Set rs_Max = Server.CreateObject("ADODB.Recordset")
'***从会员信息表(DB_Member)中取出最大的会员ID。
sql_max="SELECT MAX(ID) AS MaxID FROM DB_Member"
rs_max=conn.execute(sql_max)
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>注册新会员</title>
<link href="style.css" rel="stylesheet">
<style type="text/css">
<!--
body {
background-image: url(images/bg1.jpg);
}
-->
</style>
</head>
<body leftmargin="0" topmargin="0">
<center>
<table width="640" height="133" border="0" cellpadding="-1" cellspacing="-1">
<tr>
<td background="images/bg.jpg"><img src=http://tech.ddvip.com/2006-10/"images/register_top.gif" width="640" height="130"></td>
</tr>
</table>
<table width="640" height="341" border="0" cellpadding="-1" cellspacing="-1" background="images/bg.jpg">
<tr>
<td valign="top" background="images/buycar_bottom.jpg">
<div align="center">
<!--开始创建表单-->
<form method="POST" action="register.asp" name="form1">
<table width="346" border="1" align="center" cellpadding="0"
cellspacing="0" bordercolor="#FFFFFF" bordercolorlight="#FFFFFF"
bordercolordark="#aaaaFF">
<tr>
<!--开始按一定的规则自动生成会员ID-->
<% no=trim(rs_max("MaxID"))
'从rs_max记录集中取出字段名为“MaxID"的值,它就是当前最大的会员ID。
'下面分别取出当前的月、日和年的值,作为新会员编号的头部。如果取出的月和日的值为一位数,则在其前添加一个0。
if len(month(date()))=1 then
cmonth="0"& cstr(month(date()))
else
cmonth=cstr(month(date()))
end if
if len(day(date()))=1 then
cday="0"& cstr(day(date()))
else
cday=cstr(day(date()))
end if
'下面取出新会员编号的后5位的值。
select case len(int(Right(no,5)+1))
'当从变量(no)中由右向左取5个字符串加1后,其值的长度等于1,则将其值前加上0000后赋给变量cno。
case 1
cno="0000"+Cstr(int(Right(no,5)+1))
case 2
cno="000"+Cstr(int(Right(no,5)+1))
case 3
cno="00"+Cstr(int(Right(no,5)+1))
case 4
cno="0"+Cstr(int(Right(no,5)+1))
case 5
cno=Cstr(int(Right(no,5)+1))
case Else
cno="00001"
end select
intno="HY"& cStr(Year(Date()))& cmonth& cday&cno
%>
<td width="82" height="27" align="right" nowrap>会员ID:</td>
<td width="258" height="27"> 
<input type="hidden" name="ID" value="<%= intno %>" size="32">
<font color="#666699"><%= intno %></font></td>
</tr>
<tr>
<td height="27" align="right" nowrap>会员名称:</td>
<td height="27"> <div align="center">
<input type="text" name="mName" size="32">
</div></td>
</tr>
<tr>
<td height="27" align="right" nowrap>您的密码:</td>
<td height="27"> <div align="center">
<input type="password" name="PassWord" value="" size="32">
</div></td>
</tr>
<tr>
<td height="27" align="right" nowrap>城市:</td>
<td height="27"> <div align="center">
<input type="text" name="city" value="" size="32">
</div></td>
</tr>
<tr>
<td height="27" align="right" nowrap>地址:</td>
<td height="27"> <div align="center">
<input type="text" name="address" value="" size="32">
</div></td>
</tr>
<tr>
<td height="27" align="right" nowrap>邮政编码:</td>
<td height="27"> <div align="center">
<input name="postcode" type="text" value="" size="32" maxlength="6">
</div></td>
</tr>
<tr>
<td height="27" align="right" nowrap>信用卡号:</td>
<td height="27"> <div align="center">
<input name="CardNO" type="text" value="" size="32" maxlength="24">
</div></td>
</tr>
<tr>
<td height="27" align="right" nowrap>信用卡类型:</td>
<td height="27"> <div align="center">
<input type="text" name="CardType" value="" size="32">
</div></td>
</tr>
<tr>
<td height="27" align="right" nowrap>联系电话:</td>
<td height="27"> <div align="center">
<input type="text" name="Tel" value="" size="32">
</div></td>
</tr>
<tr>
<td height="27" align="right" nowrap>Email:</td>
<td height="27"> <div align="center">
<input type="text" name="Email" value="" size="32">
</div></td>
</tr>
<!--创建表单结束-->
<script language="JavaScript">
//创建一个名为myreset的自定义函数。
function myreset(){
//执行表单重填。
form1.reset();
event.returnValue=false;
}
</script>
<script language="VBScript">
'创建一个名为mysubmit的自定义函数。当表单中某项内没有填写数值时,一提交,此函数就显示相应的提示信息。
function mysubmit()
if form1.mName.value="" then
msgbox "请输入会员姓名!"
form1.mName.focus()
end if
if form1.PassWord.value="" then
msgbox "请输入会员密码!"
form1.PassWard.focus()
end if
if form1.city.value="" then
msgbox "请输入城市!"
form1.city.focus()
end if
if form1.address.value="" then
msgbox "请输入地址!"
form1.address.focus()
end if
if form1.Postcode.value="" then
msgbox "请输入邮政编码!"
form1.Postcode.focus()
end if
if form1.CardNO.value="" then
msgbox "请输信用卡号!"
form1.CardNO.focus()
end if
if form1.Tel.value="" then
msgbox "请输入联系电话!"
form1.Tel.focus()
end if
if form1.Email.value="" then
msgbox "请输入Email!"
form1.Email.focus()
end if
end function
</script>
<table>
<tr>
<td width="314" height="49" align="right">
<div align="center">
<input type="image" value="提交" src=http://tech.ddvip.com/2006-10/"images/submit.gif" onClick="return mysubmit()">
<input type="image" name="Submit" value="重置" src=http://tech.ddvip.com/2006-10/"images/reset.gif" onClick="myreset()">
<a href="checkout.asp"><img src=http://tech.ddvip.com/2006-10/"images/home1.gif" width="81" height="36" border="0"></a>
<input name="Amount" type="hidden" id="Amount" value="0">
<input name="grade" type="hidden" id="grade" value="0">
</div></td>
</tr>
</table>
</center>
</body>
</html>

Register_OK.asp 显示注册会员成功信息页面。 本页面是注册注册成功提示页面。其主要功能有:

上一页  4 5 6 7 8 9 10  下一页

Tags:ASP 入门 基础

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接