asp 注册代码实现

我的只是独立的。你自己试着组合下:
1.<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>欢迎光临</title>
</head>
<%
Session.Timeout=10
if session("pass")<>"action1" then
response.Redirect("logon.asp")
Response.End
end if
%>
<body>
<h1 align="center"> </h1>
<h1 align="center">登录成功! </h1>
</body>
</html>


2.<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>注册结果</title>
</head>
<!--#include file=security.asp-->
<body>
<p> </p>
<p> </p>
<h2 align="center">
<%
dim db '以下连上数据库,建立一个Connection对象实例db
set db=Server.Createobject("ADODB.Connection")
db.Open "DBQ="&Server.Mappath("maindata.asa")&";DRIVER={Microsoft Access Driver (*.mdb)};"

dim strSql,rs,strSql1
strSql="Select * From user"
set rs=db.execute(strSql)

dim a1,a2,b2,c2,a3,a4,a5,a6,i
a1=Request.Form("user")
a2=Request.Form("password")
b2=Request.Form("password2")
a3=Request.Form("sex")
a4=Request.Form("love")
a5=Request.Form("career")
a6=Request.Form("introduction")
'下面是检查用户名和密码是否填写完整
if trim(a1)="" or trim(a2)="" then
Response.Write "对不起,用户名、密码必须填写!<p>"
Response.Write "<a href='login.asp' >重填</a>"
Response.End
end if
'下面将注册用户名,逐条与数据库是记录的用户名对比。如果数据库中已经有了,提示用户不能再注册。
do while not rs.Eof
i=rs("user_name")
if trim(a1)=trim(i) then
Response.Write "用户名重名<p>"
Response.Write "<a href='login.asp' >重填</a>"
Response.End
end if
rs.movenext
loop
'下面是检查密码与确认密码是否相同
if a2 <> b2 then
Response.Write "密码确认不正确<p>"
Response.Write "<a href='login.asp' >重填</a>"
Response.End
end if
c2=encrypt(a2)
'下面是将注册信息添加到数据库中
strsql="insert into user(user_name,password,sex,love,career,introduction,submit_date) Values('"& a1 & "', '"& c2 &"', '" & a3 &"','"& a4 & "','"& a5 & "','"& a6 & "', #" & now() & "#)"
db.Execute(strsql)
%>
</h2>
<h2 align="center" >
<%
Response.Write "注册成功!<p>请记牢用户名和密码!"
%>
</h2>
<p align="center" class="base-4" > </p>
<table width="121" height="35" border="0" align="center" cellpadding="0" cellspacing="0">
<tr align="middle">
<td><script language="JavaScript">
function shutwin(){
window.close();
return;}
</script> <a href="javascript:shutwin();">关闭本窗口</a></td>
</tr>
</table>
<p align="center" > </p>
<p>

</body>
</html>


3.<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>注册</title>
</head>

<body>
<p> </p><p> </p>
<table width="600" border="0" align="center">
<tr>
<td><h2 align="center">用户注册</h2>
<form name="form1" method="post" action="insert.asp">
<table width="67%" border="1" align="center" cellspacing="0" bordercolor="#0000FF">
<tr>
<th width="25%">用户名</th>
<td width="75%"><input type="text" name="user">
** 必须填写</td>
</tr>
<tr>
<th>密码</th>
<td><input type="password" name="password" >
**</td>
</tr>
<tr>
<th width="25%">确认密码</th>
<td width="75%"><input type="password" name="password2">
**</td>
</tr>
<tr>
<th width="25%">性别</th>
<td width="75%"><input type="radio" name="sex" value="男">

<input type="radio" name="sex" value="女">
女</td>
</tr>
<tr>
<th width="25%">爱好</th>
<td width="75%"><input type="checkbox" name="love" value="音乐">
音乐
<input type="checkbox" name="love" value="计算机">
计算机</td>
</tr>
<tr>
<th width="25%">职业</th>
<td width="75%"><select name="career" size="1">
<option value=" " selected>请选择</option>
<option value="教育业">教育业</option>
<option value="金融业">金融业</option>
<option value="其他">其他</option>
</select></td>
</tr>
<tr>
<th width="25%">简介</th>
<td width="75%"><textarea name="introduction" cols="40" rows="2" wrasp="soft"></textarea></td>
</tr>
<tr>
<th> </th>
<td><input type="submit" name="Submit" value="提交">

<input type="submit" name="teset" value="重写"> </td>
</tr>
</table>
</form>
</td>
</tr>
</table>
<h2 align="center"> </h2>
</body>
</html>


4.<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>注册</title>
</head>

<body>
<p> </p><p> </p>
<table width="600" border="0" align="center">
<tr>
<td><h2 align="center">用户登录</h2>
<form name="form1" method="post" action="validate.asp">
<table width="67%" border="1" align="center" cellspacing="0" bordercolor="#0000FF">
<tr>
<th width="25%">用户名</th>
<td width="75%"><input name="user" type="text" size="20">
</td>
</tr>
<tr>
<th>密码</th>
<td><input name="password" type="password" size="20" > </td>
</tr>

<tr>

<th> 附加码</th>
<td><input type="text" name="otherpwd" size="20" class="button1">

<%
dim temprnd '随机生成 附加码
Randomize
temprnd=cstr(Int((9999 - 1000 + 1) * Rnd() + 1000))
response.Write (temprnd)
%>
<input type="hidden" name="reotherpwd" value="<%=temprnd%>">
</td>
</tr>

<tr>
<th> </th>
<td><input type="submit" name="Submit" value="提交">

<input type="submit" name="teset" value="重写"> </td>
</tr>
</table>
</form>
</td>
</tr>
</table>
<h2 align="center"> </h2>
</body>
</html>


5.<%
function decrypt(dcode)
dim texts
dim i
for i=1 to len(dcode)
texts=texts & chr(asc(mid(dcode,i,2))-i)
next
decrypt=texts
end function
function encrypt(ecode)
Dim texts
dim i
for i=1 to len(ecode)
texts=texts & chr(asc(mid(ecode,i,2))+i)
next
encrypt = texts
end function
%>

6.<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file=security.asp-->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>登录网页</title>
</head>
<body>
<p> </p>
<p> </p>
<h2 align="center">
<%
rem 以下连上数据库,建立一个Connection对象实例db
dim db
set db=Server.Createobject("ADODB.Connection")
db.Open "DBQ="&Server.Mappath("maindata.asa")&";DRIVER={Microsoft Access Driver (*.mdb)};"
dim strSql,rs,strSql1
strSql="Select * From user"
set rs=db.execute(strSql)

dim a1,a2,nam,psw,otherpwd,reotherpwd
a1=Request.Form("user")
a2=Request.Form("password")
otherpwd=Request.Form("otherpwd")
reotherpwd=Request.Form("reotherpwd")

do while not rs.Eof
nam=rs("user_name")
rem 利用decrypt解密函数不原密码
psw=decrypt(rs("password"))
if reotherpwd<>otherpwd then
Response.Write "附加码不对!<p>"
Response.Write "<a href='logon.asp' >重新登录</a>"
Response.End
end if
rem 如果用户名、密码正确,登录成功,引导到另一张网页
if a1=nam and a2=psw then
session("pass")="action1"
response.Redirect("default.asp")
Response.End
end if
rs.movenext
loop
Response.Write "用户信息不正确<p>"
Response.Write "<a href='logon.asp' >重新登录</a>"
%>
</h2>

</body>
</html>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值