?? savereg.asp
字號:
<!--#include file="conn.asp"-->
<%'===========================驗證表單內容是否合法(開始)====================================================================%>
<%
username=trim(request.form("username"))
password=trim(request.form("password"))
password2=trim(request.form("password2"))
name=trim(request.form("name"))
tel=trim(request.form("tel"))
shouji=trim(request.form("shouji"))
youbian=trim(request.form("youbian"))
mail=trim(request.form("mail"))
dizhi=trim(request.form("dizhi"))
danwei=trim(request.form("danwei"))
if username="" or password="" or password2="" or name="" or tel="" or shouji="" or youbian="" or mail="" or dizhi="" or danwei="" then
response.write "<SCRIPT language=JavaScript>alert('為了保證編輯部能和您成功聯系,所有項目必須認真填寫');"
Response.Write"this.location.href='vbscript:history.back()';</SCRIPT>"
Response.End
end if
if instr(Request("username")," ")>0 or instr(Request("username"),"'")>0 then
response.write "<SCRIPT language=JavaScript>alert('用戶名中含有非法字符');"
Response.Write"this.location.href='vbscript:history.back()';</SCRIPT>"
Response.End
end if
if len(username)>8 or len(username)<2 then
response.write "<SCRIPT language=JavaScript>alert('用戶名不能大于8小于2');"
Response.Write"this.location.href='vbscript:history.back()';</SCRIPT>"
Response.End
end if
if len(password)>16 or len(password)<6 then
response.write "<SCRIPT language=JavaScript>alert('密碼長度為6-16個字符');"
Response.Write"this.location.href='vbscript:history.back()';</SCRIPT>"
Response.End
end if
if password<>password2 then
response.write "<SCRIPT language=JavaScript>alert('密碼和確認密碼不一致');"
Response.Write"this.location.href='vbscript:history.back()';</SCRIPT>"
Response.End
end if
if not(isnumeric(shouji)) then
response.write "<SCRIPT language=JavaScript>alert('手機號碼必須是數字');"
Response.Write"this.location.href='vbscript:history.back()';</SCRIPT>"
Response.End
end if
if not(isnumeric(youbian)) or len(youbian)<>6 then
response.write "<SCRIPT language=JavaScript>alert('請正確輸入郵編');"
Response.Write"this.location.href='vbscript:history.back()';</SCRIPT>"
Response.End
end if
if not(isnumeric(youbian)) then
response.write "<SCRIPT language=JavaScript>alert('郵編必須是數字');"
Response.Write"this.location.href='vbscript:history.back()';</SCRIPT>"
Response.End
end if
if len(dizhi)<10 then
response.write "<SCRIPT language=JavaScript>alert('請填寫詳細地址');"
Response.Write"this.location.href='vbscript:history.back()';</SCRIPT>"
Response.End
end if
if len(dizhi)>60 then
response.write "<SCRIPT language=JavaScript>alert('地址不能大于30字');"
Response.Write"this.location.href='vbscript:history.back()';</SCRIPT>"
Response.End
end if
if instr(Request("mail"),"@")=0 or instr(Request("mail"),".")=0 then
response.write "<SCRIPT language=JavaScript>alert('請按正確格式填寫E-mail地址!');"
response.write "this.location.href='vbscript:history.back()';</SCRIPT>"
response.end
end if
'===================驗證表單內容是否合法(結束)======================
'===============================驗證是否有重復申請(開始)===============
set rs=server.CreateObject("adodb.recordset")
sql="select * from user where username='"&cstr(username)&"'"
rs.open sql,conn,1,2
if rs.recordcount>0 then
response.write "<script language=javascript>"
response.write "alert('已經有此用戶了!');"
response.write "javascript:history.go(-1);"
response.write "</script>"
Response.end
else
set rs=server.CreateObject("adodb.recordset")
rs.open "select * from user where mail='"&mail&"'" ,conn,1,1
if rs.recordcount>0 then
response.write "<script language=javascript>"
response.write "alert('同一用戶只可申請一個!');"
response.write "javascript:history.go(-1);"
response.write "</script>"
Response.end
else
'========================驗證是否有重復申請(結束)以下是將表單的內容插入到數據庫中============================
set rs=server.createobject("adodb.recordset")
sql="select * from user"
rs.open sql,conn,1,2
rs.addnew
rs("username")=username
rs("name")=name
rs("password")=password
rs("tel")=tel
rs("youbian")=youbian
rs("dizhi")=dizhi
rs("mail")=mail
rs("shouji")=shouji
rs("danwei")=danwei
rs("date")=date()'=在數據庫里插入當前的時間,格式為年,月,日
rs.update
rs.close
conn.close
set rs=nothing
end if
end if
'===========================================插入結束=============================
%>
<html>
<head>
<link href="style.css" rel="stylesheet" type="text/css">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta http-equiv="refresh" content="1;URL=index.asp">
<style type="text/css">
<!--
body,td,th {
font-family: Arial, Helvetica, sans-serif;
font-size: 16px;
}
a {
font-family: Arial, Helvetica, sans-serif;
font-size: 16px;
}
-->
</style></head>
<body>
<div align="center">會員申請成功</div>
</body>
</html>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -