用户注册及跟踪代码(二)
网络整理 - 07-26
2. ASP代码(设立一DSN,请改动begin.asp)----------------------------------
------文件begin.asp
<%
Set Con = Server.CreateObject( "ADODB.Connection" )
Con.Open "test" ,"test","test"
%>
-----文件reg_step1.asp
<html>
<head>
<title>会员注册--基本信息</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<script LANGUAGE="Javascript1.1">
function verifyIt(form) {
for (i = 0; i <document.forms[0].elements.length; i++) {
if (document.forms[0].elements[i].type == "text" && document.forms[0].elements[i].value == ""){
alert("所有内容必须填写!")
return false;
}
}
if (document.forms[0].n_pass.value.length<6){
alert("密码不得少于6位")
return false
}
if (document.forms[0].n_pass.value!=document.forms[0].nq_pass.value){
alert("密码与确认密码不一致!")
document.forms[0].n_pass.value=""
document.forms[0].nq_pass.value=""
return false;
}
return true;
}
</script>
</head>
<body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" text="#333333">
<table cellspacing="0" cellpadding="0">
<tr>
<td> </td>
</tr>
<tr>
<td>
<table cellspacing="0" cellpadding="0">
<tr>
<td valign="top" > </td>
<td valign="top">
<table cellspacing="0" cellpadding="0">
<tr>
<td valign="top"> </td>
<td valign="top"> </td>
</tr>
<tr>
<td valign="top">
<table cellspacing="0" cellpadding="0">
<tr>
<td valign="top"> </td>
<td valign="top">
<form action="reg_step1_sub.asp" method="post">
<table cellspacing="0" cellpadding="0">
<tr>
<td><font color="#336600">新会员注册-基本信息</font>
<hr size="1" color="#669999">
</td>
</tr>
<tr valign="top">
<td>
<table>
<tr>
<td><font color="#336600">用户名:</font></td>
<td>
<input type="text" size="20">
</td>
</tr>
<tr>
<td><font color="#336600">密码:</font></td>
<td>
<input type="password" size="20">
<font color="#336600"> 至少6位</font></td>
</tr>
<tr>
<td><font color="#336600">确认密码:</font></td>
<td>
<input type="password" size="20">
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<hr size="1" color="#669999">
<input type="submit" value="申请">
<input type="reset" value="重填">
</td>
</tr>
<tr>
<td> </td>
</tr>
</table>
</form>
</td>
</tr>
</table>
</td>
<td valign="top"> </td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td> </td>
</tr>
</table>
</body>
</html>
---文件reg_step1_sub.asp
<%
u_name=Request.Form("n_name")
u_pass=Request.Form("n_pass")
if u_name="" and u_pass="" then
Response.Redirect "reg_step1.asp"
Response.end
end if
%>
<!-- #include file = "../inc/adovbs.inc" -->
<!-- #include file = "../inc/begin.asp" -->
<html>
<head>
<title>会员注册</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link href="../css/sty1.css" type="text/css">
</head>
<body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" text="#333333">
<table cellspacing="0" cellpadding="0">
<tr>
<td> </td>
</tr>
<tr>
<td>
<table cellspacing="0" cellpadding="0">
<tr>
<td valign="top"> </td>
<td valign="top">
<table cellspacing="0" cellpadding="0">
<tr>
<td valign="top"> </td>
<td valign="top"> </td>
</tr>
<tr>
<td valign="top">
<table cellspacing="0" cellpadding="0">
<tr>
<td valign="top"> </td>
<td valign="top">
<p>
<%
if trim(u_name)="" then
Response.write "<div><a href='javascript:history.go(-1)'>用户名不能为空格,返回。</a></div>"
Response.write "</body></html>"
Response.end
else
u_name=rtrim(trim(u_name))
end if
if instr(u_name," ")<>0 then
Response.write "<div><a href='javascript:history.go(-1)'>用户名中不能包含空格,返回。</a></div>"
Response.write "</body></html>"
Response.end
end if
if instr(u_pass," ")<>0 then
Response.write "<div><a href='javascript:history.go(-1)'>密码中不能包含空格,返回。</a></div>"
Response.write "</body></html>"
Response.end
end if
Set MyCommand=Server.CreateObject("ADODB.Command")
Set MyCommand.ActiveConnection=Con
MyCommand.CommandType=adCmdStoredProc
MyCommand.CommandText="proc_UserRegBase"
MyCommand.Parameters.Append MyCommand.CreateParameter("u_name",adVarChar,adParamInput,30)
MyCommand.Parameters.Append MyCommand.CreateParameter("u_pass",adVarChar,adParamInput,30)
MyCommand.Parameters("u_name")=u_name
MyCommand.Parameters("u_pass")=u_pass
Set RS=MyCommand.Execute()
'Set RS=Server.CreateObject("ADODB.RecordSet")
'strSql="proc_userRegBase '"&u_name&"','"&u_pass&"'"
'SET RS=Con.Execute(strSql)
check_reg=RS("resultID")
if check_reg=0 then
set RS=rs.NextRecordSet
VailCodeLogin=rtrim(trim(RS("ValidCodeLogin")))
Session("lotto_isLogin")=rtrim(trim(RS("ValidCodeLogin")))
Session("lotto_username")=u_name
end if
RS.Close
Con.Close
%>
<%if check_reg=0 then%>
</p>
<table cellspacing="0" cellpadding="0">
<tr>
<td><font color="#336600">注
册 成 功!</font></td>
</tr>
<tr>
<td>
<hr size="1" color="#669999">
</td>
</tr>
<tr>
<td>
<p>用户名:<b><%=u_name%></b><br>
密码:<b><%=u_pass%></b></p>
</td>
</tr>
<tr>
<td>
<hr size="1" color="#669999">
<table cellspacing="0" cellpadding="0">
<tr>
<td colspan="2">按<a href="reg_step2.asp?VailCodeLogin=<%=VailCodeLogin%>&name=<%=u_name%>"><font color="#336600">这里</font></a>,<a href="reg_step2.asp?VailCodeLogin=<%=VailCodeLogin%>&name=<%=u_name%>"><font color="#336600">填写详细的个人资料</font></a>。</td>
</tr>
<tr>
<td colspan="2"> </td>
</tr>
<tr>
<td> </td>
<td><font color="#000000">注意,请仔细阅读下列事项:</font></td>
</tr>
<tr>
<td colspan="2" valign="top">
<hr size="1" color="#669999">
</td>
</tr>
<tr>
<td valign="top">1.</td>
<td>如果您想进行网上订购, 必须填写更详细的个人资料。</td>
</tr>
<tr>
<td valign="top">2.</td>
<td>如果您想以后填写, 请在登录状态,进入"彩民社区"-"用户服务"
功能区填写。</td>
</tr>
<tr>
<td valign="top"> </td>
<td> </td>
</tr>
</table>
</td>
</tr>
<tr>
<td> </td>
</tr>
</table>
<%end if%>
<%if check_reg=-1 then%>
<table cellpadding="0" cellspacing="0">
<tr>
<td> </td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td><a href="javascript:history.go(-1)">该用户名已经存在,返回。</a></td>
</tr>
</table>
<%end if%>
</td>
</tr>
</table>
</td>
<td valign="top"> </td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>
