📄 regpost.asp
字号:
<html>
<head>
<title>用户注册情况!</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<BODY vLink=#333333 aLink=#333333 link=#333333 bgColor=#ffffff leftMargin=0
topMargin=0><LINK href="forum.css" type=text/css
rel=stylesheet>
<TABLE cellSpacing=0 cellPadding=1 width="95%" align=center bgColor=#777777
border=0>
<TBODY>
<TR>
<TD>
<TABLE style="COLOR: #000000" cellSpacing=0 cellPadding=4 width="100%"
border=0 bgcolor="#a9d46d">
<TBODY>
<tr>
<td width="27%" height="2"><font color="#FF0000">>></font>欢迎您,<b><%if session("loginname")="" then %>请先登录!<%end if%><%=session("loginname")%></b></td>
<td width="62%" height="2"><img src="images/reg.gif" width="16" height="16" align="absmiddle"><a href="reg.asp">用户注册</a>|<img src="images/login.gif" width="16" height="16"><a href="login.asp">用户登录</a>|<img src="images/update.gif" width="16" height="16"><a href="usermodify.asp">修改资料</a>|<img src="images/message.gif" width="21" height="14">现在时间:<%=now()%></td>
<td width="11%" height="2">
<div align="right"><img src="images/home.gif" width="14" height="14" align="absmiddle">返回首页</div>
</TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE>
<!--#include file="regpostbody.asp"-->
<%
'取得计数文件名及路径
Function getcounterfilename()
dim fullpath,pointposition
fullpath=Request.ServerVariables("PATH_TRANSLATED")
Pointposition=InstrRev(fullpath,".")
getcounterfilename=Mid(fullpath,1,pointposition)&"cnt"
set obj=createobject("scripting.filesystemobject")
'判断计数文件是否存在,如果没有,则创建
if obj.fileexists(getcounterfilename)=false then
set creat=obj.createtextfile(getcounterfilename,true)
creat.writeline("username")
creat.close
end if
end function
'密码转换函数
Function encryptpwd(passwd)
dim leghth, i, newpasswd
dim temp
dim head, tail
passwd=left(passwd,10)
length=len(passwd)
newpasswd=""
for i=1 to length
temp=mid(passwd,i,1)
temp=asc(temp)
head=temp mod 16
tail=temp\16
temp=(head*16)+tail
if cint(temp)<100 and cint(temp)>10 then
temp="0"&temp
else
if cint(temp)<10 then
temp="00"&temp
end if
end if
newpasswd=newpasswd&temp
next
encryptpwd=newpasswd
end function
'检验是否有相同的用户名已注册
Function checkuser()
Dim conn
Set conn=Server.CreateObject("ADODB.Connection")
conn.Open "driver={Microsoft Access Driver (*.mdb)};dbq="& Server.MapPath("db\rainolt.mdb")
username=sqlstr(trim(Request.Form("username")))
sql="select * from user where username='"&username&"'"
set record=conn.Execute(sql)
if record.EOF then
checkuser=False
Else
checkuser=True
End if
record.close
conn.close
End function
'将数据中的单引号转化为双引号,并且在前面加单引号
Function Sqlstr(data)
sqlstr=Replace(data,"'","''")
End Function
%>
<%
If NOT checkuser() Then
username=sqlstr(trim(Request.Form("username")))
passwd=encryptpwd(Request.Form("psw"))
sex=Request.Form("SEX")
face=Request.Form("face")
oicq=Request.Form("oicq")
page=sqlstr(trim(Request.Form("homepage")))
email=sqlstr(trim(Request.Form("email")))
artnum=clng(1)
reply=clng(0)
IP = Request.ServerVariables("REMOTE_ADDR")
address=sqlstr(trim(request.form("address")))
pyear=year(date)
pmonth=month(date)
pday=day(date)
regtime=cstr(pyear&"-"&pmonth&"-"&pday)
Dim conn
Set conn=Server.CreateObject("ADODB.Connection")
conn.Open "driver={Microsoft Access Driver (*.mdb)};dbq="& Server.MapPath("db\rainolt.mdb")
sql="INSERT INTO user(username,psw,email,oicq,face,sex,page,artnum,reply,ip,address,regtime) values("
sql=sql&"'"&username&"','"&passwd&"','"&email&"','"&oicq&"','"&face&"','"
sql=sql&sex&"','"&page&"','"&artnum&"','"&reply&"','"&ip&"','"&address&"','"®time&"')"
conn.Execute(sql)
'将新的注册用户写入记录文件
set obj=createobject("scripting.filesystemobject")
counterfilename=getcounterfilename()
response.write couterfilename
set write=obj.createtextfile(counterfilename,-1,0)
write.writeline username
write.close
conn.close
session("loginname")=request.form("username")
session("password")=request.form("psw")
%>
<table width="70%" border="0" align="center" bgcolor="#777777" cellpadding="1" cellspacing="1">
<tr bgcolor="#a9d46d">
<td colspan="2" height="20">
<div align="center"><b>注册成功</b></div>
</td>
</tr>
<tr bgcolor="#f4faed">
<td colspan="2">姓名:<img src="images\<%=face%>.bmp"><font color="#FF0000"><%=username%></font></td>
</tr>
<tr bgcolor="#f4faed">
<td width="50%">密码:<%=request.form("psw")%></td>
<td width="50%">来自:<%=address%></td>
</tr>
<tr bgcolor="#f4faed">
<td width="50%">性别:<%=sex%></td>
<td width="50%">IP地址:<%=ip%></td>
</tr>
<tr bgcolor="#f4faed">
<td width="50%">Email:<%=email%></td>
<td width="50%">OICQ:<%=oicq%></td>
</tr>
<tr>
<td colspan="2" bgcolor="#f4faed">Homepage:<%=page%></td>
</tr>
<tr>
<td colspan="2" bgcolor="#a9d46d" height="20">
<div align="center"><a href='index.asp'>返回论坛</a></div>
</td>
</tr>
</table>
<%else%>
<table width="70%" border="0" align="center" bgcolor="#777777" cellspacing="1" cellpadding="1">
<tr>
<td bgcolor="#a9d46d" height="20">
<div align="center"><b>注册失败</b></div>
</td>
</tr>
<tr>
<td height="21" bgcolor="#f4faed"><li>该用户已经被注册,请你点击返回,修改!</li>
(<a href='javascript:history.back()'>返回</a>)</td>
</tr>
<tr>
<td bgcolor="#a9d46d" height="20"> </td>
</tr>
</table>
<%end if
%>
<!--#include file="footer.asp"-->
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -