⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dealnewuser.asp

📁 一个网站聊天室的模型
💻 ASP
字号:
<%@ Language=VBScript CODEPAGE="936"%>
<!--#include file="conn.asp"-->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<HTML>
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</HEAD>
<BODY>
<%
'处理newuser.asp页面提交的信息
	dim mysql
	dim NewUserID,NewUserPWD,NewUserNickName,NewUserName
	'使用request的form集合来取得从newuser.asp页面的表单中提交的数据信息,分别赋给各变量
	NewUserID=Request.Form("uid")'用户名
	NewUserPWD=Request.Form("pwd1")'密码
	NewUserName=Request.Form("realname")'用户的真实姓名
	age=Request.Form("age")'年龄
	birthday=Request.Form("birthday")'出生日期
	certificatetype=Request.Form("certificatetype")'证件类型
	certificatenumber=Request.Form("certificatenumber")'证件号码
	Email=Request.Form("email")'邮箱地址
	question=Request.Form("question")'密码提示问题
	answer=Request.Form("answer")'密码提示答案
	'创建记录集对象
	set myrecord=server.CreateObject ("ADODB.Recordset")
	mysql="select * from User where UserID='" & NewUserID & "'"
	'打开记录集对象
	myrecord.Open mysql,conn,1,3
	
	if not myrecord.BOF then'如果新提交的用户名已经存在,就...
	'向浏览器输出信息
		Response.Write "该用户名已经存在,请换一个用户名"
		Response.Write "<a href='NewUser.asp'>重新注册</a>"
		'终止当前程序的执行,此后的程序都不再执行
		Response.End()
	else
		'如果没有与已注册的用户重名,就在user表中增加一条新记录 
		myrecord.AddNew 
			myrecord("UserID")=NewUserID
			myrecord("PWD")=NewUserPWD
			'对于要求不是必须填写的项要判断它是否为空
			if NewUserName<>"" then
				myrecord("Name")=NewUserName
			end if
			if Request.Form("male")<>"" then
				myrecord("sex")="男"
				elseif Request.Form("female")<>"" then
				myrecord("sex")="女"
			end if
			'年龄要求输入数字
			if age<>"" then
			if isnumeric(age)=true then
			'isnumeric是判断其内容是否为数字的函数
				myrecord("age")=age
				else
%>
<script language="javascript">
<!--
window.alert ("年龄必须为数字!请重新输入年龄!")//弹出警告对话框
location.href ="newuser.asp"//重新回到信息填写页面
//-->
</script>
<%
'取消此次加入新记录操作所做的修改
'CancelUpdate方法可以取消在调用Update方法之前所做的一切修改
myrecord.cancelupdate
'终止当前程序的执行,此后的程序都不再执行
response.End()
end if
			end if
			if birthday<>"" then
				myrecord("birthday")=birthday
			end if
				myrecord("certificatetype")=certificatetype
			if certificatenumber<>"" then
				myrecord("certificatenumber")=certificatenumber
			end if
			'email要求按email格式输入
			if email<>"" then
			'instr是判断email字符串中是否有@字符的函数,如果没有@字符,就提示用户格式不正确
			'然后取消此次加入新记录操作所做的修改
			if instr(email,"@")=0 then
%>
<script language="javascript">
<!--
window.alert ("Email格式不正确!请重新输入Email!")
location.href ="newuser.asp"
//-->
</script>
<%
'取消此次加入新记录操作所做的修改
'CancelUpdate方法可以取消在调用Update方法之前所做的一切修改
myrecord.cancelupdate
'终止当前程序的执行,此后的程序都不再执行
response.End()
else
				myrecord("email")=email
			end if
			end if
			if question<>"" then
				myrecord("pwdquestion")=question
			end if
			if answer<>"" then
				myrecord("pwdanswer")=answer
			end if
			'如果所填写的内容都符合要求,就更新user表
		myrecord.Update
		'Update方法表示将myrecord对象中的当前记录的任何修改保存在数据源中
		Response.Write ("恭喜你,你已经注册成功,你现在可以<a href='index.asp'>登录聊天室</a>了!")
		
	end if'与if not myrecord.BOF then语句相对应
	'关闭记录集对象,但在执行set myuser=nothing语句之前该记录集仍然存在
	myrecord.Close
	set myrecord=nothing
	'关闭数据源连接对象
conn.Close 
set conn=nothing

%>
</BODY>
</HTML>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -