登录系统asp源代码的简单介绍
admin 发布:2022-12-19 19:23 112
本篇文章给大家谈谈登录系统asp源代码,以及对应的知识点,希望对各位有所帮助,不要忘了收藏本站喔。
本文目录一览:
asp程序实现简单的注册,登录网页的源代码
1,(index.asp 用户登陆页面)
!-- #include file="conn.asp" --
!-- blog.soowooo.cn 悠悠长假期 --
html
head
meta http-equiv="Content-Type" content="text/html; charset=gb2312"
title会员/title
style type="text/css"
!--
body,td,th {
font-family: 宋体;
font-size: 14px;
}
--
/style
/head
body
center
p会员注册系统/p
form name="form1" method="post" action="login.asp"
table width="34%" border="0"
tr
td width="33%" height="30"用户名:/td
td width="67%" height="30"input name="username" type="text" id="username" size="15"/td
/tr
tr
td height="30"密 码:/td
td height="30"input name="password" type="password" id="password" size="15"/td
/tr
tr
td colspan="2" align="center"input type="submit" name="Submit" value="确定"
input type="reset" name="Submit" value="重置"/td
/tr
tr
td colspan="2"a href="reg.asp" target="_self"注册/a/td
/tr
/table
/form
/center
/body
/html
2,(login.asp 用户数据处理文件)
!-- #include file="conn.asp" --
%
'打开数据库判断用户是否存在,info为表名,username为字段名
set rsc=server.createobject("adodb.recordset")
sqlc="select * from info where username='"request.Form("username")"' and password='"request.Form("password")"'"
rsc.open sqlc,conn,1,1
session("username")=rsc("username")
session("password")=rsc("password")
session.Timeout=30
set rsc=nothing
response.Redirect("change.asp")
'如果用户不存在,session("username")为空
%
3,(change.asp 用户信息修改页面)
!-- #include file="conn.asp" --
html
head
meta http-equiv="Content-Type" content="text/html; charset=gb2312"
title修改/title
style type="text/css"
!--
body,td,th {
font-size: 14px;
}
--
/style/head
center
body
br
%
set rsc=server.createobject("adodb.recordset")
sqlc="select * from info where username='"session("username")"' and password='"session("password")"'"
rsc.open sqlc,conn,1,1
nr=rsc("password")
username=rsc("username")
password=rsc("password")
sex=rsc("sex")
qq=rsc("qq")
mail=rsc("mail")
add=rsc("add")
personalinfo=rsc("personalinfo")
vv=rsc("ntime")
set rsc=nothing
if nr="" then
response.Redirect("index.asp")
end if
if strcomp(nr,request.Form("password"))=0 then
response.Write("欢迎你!"request.Form("username"))
response.Write("你是在"vv"注册的")
session("username")=request.Form("username")
end if
if session("username")="" then
response.Redirect("index.asp")
end if
%
form name="form1" method="post" action="change.asp?ac=ch"
table width="39%" height="105" border="0"
tr
td width="27%" height="30"用户名:/td
td width="73%" height="30"input name="username" type="text" id="username" value="%=username%"
*/td
/tr
tr
td height="30"密 码:/td
td height="30"input name="password" type="text" id="password" value="%=password%"
*/td
/tr
tr
td height="30"性 别:/td
td height="30"input name="sex" type="text" id="sex" value="%=sex%"/td
/tr
tr
td height="30"QQ:/td
td height="30"input name="qq" type="text" id="qq" value="%=qq%"/td
/tr
tr
td height="30"Mail:/td
td height="30"input name="mail" type="text" id="mail" value="%=mail%"/td
/tr
tr
td height="30"地 址:/td
td height="30"input name="add" type="text" id="add" value="%=add%"/td
/tr
tr
td介绍/td
tdtextarea name="personalinfo" cols="30" rows="6" id="personalinfo"%=personalinfo%/textarea/td
/tr
tr
td /td
tdinput type="submit" name="Submit" value="修改"
a href="change.asp?se=y" target="_self"退出系统/a/td
% if strcomp(request.QueryString("se"),"y")=0 then
session("username")=""
response.Redirect("index.asp")
end if
%
/tr
/table
/form
%
if strcomp(request.QueryString("ac"),"ch")=0 then
set rs=server.createobject("adodb.recordset")
sql="select * from info where username='"session("username")"'"
rs.open sql,conn,1,3
rs("username")=request.Form("username")
rs("password")=request.Form("password")
rs("mail")=request.Form("mail")
rs("sex")=request.Form("sex")
rs("qq")=request.Form("qq")
rs("add")=request.Form("add")
rs("personalinfo")=request.Form("personalinfo")
rs.update
set rs=nothing
response.Write("修改完成!")
end if
%
/body
/center
/html
4,(reg.asp 新用户注册页面)
html
head
meta http-equiv="Content-Type" content="text/html; charset=gb2312"
title用户注册/title
style type="text/css"
!--
body,td,th {
font-family: 宋体;
font-size: 14px;
}
--
/style
/head
body
center
用户注册br
%
=request.QueryString("msg")
%
form name="form1" method="post" action="addnewdata.asp?ac=adduser"
table width="39%" height="105" border="0"
tr
td width="27%" height="30"用户名:/td
td width="73%" height="30"input name="username" type="text" id="username"
*/td
/tr
tr
td height="30"密码:/td
td height="30"input name="password" type="password" id="password"
*/td
/tr
tr
td height="30"确定密码:/td
td height="30"input name="password2" type="password" id="password2"
*/td
/tr
tr
td height="30"性别:/td
td height="30"input name="sex" type="text" id="sex"/td
/tr
tr
td height="30"QQ:/td
td height="30"input name="qq" type="text" id="qq"/td
/tr
tr
td height="30"Mail:/td
td height="30"input name="mail" type="text" id="mail"/td
/tr
tr
td height="30"地址:/td
td height="30"input name="add" type="text" id="add"/td
/tr
tr
td个人介绍/td
tdtextarea name="personalinfo" cols="30" rows="6" id="personalinfo"/textarea/td
/tr
tr
td /td
tdinput type="submit" name="Submit" value="提交"/td
/tr
/table
/form
/center
/body
/html
5,(addnewdata.asp 新用户注册数据处理文件)
!-- #include file="conn.asp" --
html
head
meta http-equiv="Content-Type" content="text/html; charset=gb2312"
title成功/title
/head
body
%
ac=request.QueryString("ac")
msg="注册错误信息"
if request.Form("username")="" then
msg=msg"br""用户名不能为空"
end if
if strcomp(cstr(request.Form("password")),cstr(request.Form("password2")))0 then
msg=msg"br""两次密码输入不同"
end if
if len(request.Form("password"))6 then
msg=msg"br""密码太简单"
end if
if strcomp(msg,"注册错误信息")0 then
response.Redirect("reg.asp?msg="msg)
end if
if ac="adduser" then
set rsc=server.createobject("adodb.recordset")
sql="select * from info where username='"request.Form("username")"'"
rsc.open sql,conn,1,1
ck=rsc("username")
set rsc=nothing
if ck"" then
msg=msg"br""用户名被人注册"
response.Redirect("reg.asp?msg="msg)
end if
dsql="select * from info where id is null"
set rs=server.createobject("adodb.recordset")
rs.open dsql,conn,1,3
rs.addnew
rs("username")=request.Form("username")
rs("password")=request.Form("password")
rs("mail")=request.Form("mail")
rs("sex")=request.Form("sex")
rs("qq")=request.Form("qq")
rs("add")=request.Form("add")
rs("personalinfo")=request.Form("personalinfo")
rs("ntime")=now
rs.update
set rs=nothing
%
center
a href="index.asp" target="_self"注册成功,点击登陆/a
/center
%
end if
%
/body
/html
6,(conn.asp 数据库连接文件)
%
'连接数据库开始
dim conn,rs,sql
on error resume next
dbpath=server.mappath("userinfo.mdb")
set conn=server.createobject("adodb.connection")
conn.open "PROVIDER=Microsoft.jet.OLEDB.4.0;data source="
'创建记录对象
set rs=server.createobject("adodb.recordset")
%
7,(userinfo.mdb ACCESS 数据库)
在ACCESS中建一个表,然后在这个表中建立字段名称
表名:info
字段名称 数据类型
id 自动编号
username 文本
password 文本
sex 文本
quest 文本
qq 文本
mail 文本
personalinfo 文本
ntime 文本
asp.net登录代码
aspx文件
在Web Form里:
加入两个Label控件,Text属性分别为“登录名”和“密码”;
加入两个TextBox控件,ID属性分别为“Userid”和“Pwd”,Text属性均为空;
加入两个RequiredFieldValidato控件,ID属性分别为“rfvUserid”和“rfvPwd”,Text属性分别为“请输入登录名!”和“请输入登录密码!”,ControlToValidate属性分别为"Userid"和"Pwd";
加入一个Button控件,ID属性为“LogButton”,Text属性别为“登录”;
最后加入一个Label控件,ID属性为“Msg”。
Default.aspx源代码如下:
%@ Page language="c#" Codebehind="default.aspx.cs" AutoEventWireup="false" Inherits="lsj.WebForm1" %
!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
HTML
HEAD
meta name="GENERATOR" Content="Microsoft Visual Studio 7.0"
meta name="CODE_LANGUAGE" Content="C#"
meta name="vs_defaultClientScript" content="JavaScript (ECMAScript)"
meta name="vs_targetSchema" content=""
/HEAD
body MS_POSITIONING="GridLayout"
FONT face="宋体"
form runat="server" ID="Form1"
asp:Label id="Label1" style="Z-INDEX: 101; LEFT: 82px; POSITION: absolute; TOP: 39px" runat="server" Width="55px"
Height="26px"登录名/asp:Label
asp:Label id="Label2" style="Z-INDEX: 102; LEFT: 80px; POSITION: absolute; TOP: 84px" runat="server" Width="63px" Height="24px"密 码/asp:Label
asp:TextBox id="txtuser" style="Z-INDEX: 103; LEFT: 161px; POSITION: absolute; TOP: 39px" runat="server" Width="109px" Height="25px"/asp:TextBox
asp:TextBox id="txtpsw" style="Z-INDEX: 104; LEFT: 162px; POSITION: absolute; TOP: 81px" runat="server" Width="109px" Height="22px" TextMode="Password"/asp:TextBox
asp:Button id="LogButton" style="Z-INDEX: 105; LEFT: 79px; POSITION: absolute; TOP: 125px" runat="server" Width="59px" Height="25px" Text="登 录"/asp:Button
asp:Label id="Msg" style="Z-INDEX: 106; LEFT: 161px; POSITION: absolute; TOP: 130px" runat="server" Width="117px" Height="26px"/asp:Label
asp:RequiredFieldValidator id="RequiredFieldValidator1" style="Z-INDEX: 107; LEFT: 290px; POSITION: absolute; TOP: 43px" runat="server" Width="162px" Height="18px" ErrorMessage="RequiredFieldValidator" ControlToValidate="Userid"请输入登录名!/asp:RequiredFieldValidator
asp:RequiredFieldValidator id="RequiredFieldValidator2" style="Z-INDEX: 108; LEFT: 292px; POSITION: absolute; TOP: 83px" runat="server" Width="175px" Height="22px" ErrorMessage="RequiredFieldValidator" ControlToValidate="Pwd"请输入登录密码!/asp:RequiredFieldValidator
/form
/FONT
/body
/HTML
cs文件
using System.Data.Sqlclient;
if(txtuser.Text!="" txtpsw.Text!="")
{ string connsql ="Data Source=(local);Database=StuManger; User id=sa; password=123456";//连接字符串,看着改
SqlConnection conn=new SqlConnection(connsql);
try
{
conn.Open();
}
catch(Exception ex)
{
Response.Write(ex.Message);
return;
}
string mysql="select * from [user] where userName='"+txtuser.Text+"' and psWord='"+txtpsw.Text+""; //表名和字段名也看着改
SqlCommand cmd=new SqlCommand(mysql,conn);
SqlDataReader dr=cmd.ExecuteReader();
if(dr.Read())
{
Response.Write("欢迎进入!");
}
else
{
Response.Write("对不起,您的用户名或密码不正确!");
}
conn.Close();
}
else
{
//Response.Write("用户名或密码不能为空!");
Response.Write("Script Language='JavaScript' window.alert('用户名或密码不能为空!')/Script");
return;
}
asp中的登录注册的源码怎么写?
1,(index.asp 用户登陆页面)
!-- #include file="conn.asp" --
!-- blog.soowooo.cn 悠悠长假期 --
html
head
meta http-equiv="Content-Type" content="text/html; charset=gb2312"
title会员/title
style type="text/css"
!--
body,td,th {
font-family: 宋体;
font-size: 14px;
}
--
/style
/head
body
center
p会员注册系统/p
form name="form1" method="post" action="login.asp"
table width="34%" border="0"
tr
td width="33%" height="30"用户名:/td
td width="67%" height="30"input name="username" type="text" id="username" size="15"/td
/tr
tr
td height="30"密 码:/td
td height="30"input name="password" type="password" id="password" size="15"/td
/tr
tr
td colspan="2" align="center"input type="submit" name="Submit" value="确定"
input type="reset" name="Submit" value="重置"/td
/tr
tr
td colspan="2"a href="reg.asp" target="_self"注册/a/td
/tr
/table
/form
/center
/body
/html
2,(login.asp 用户数据处理文件)
!-- #include file="conn.asp" --
%
'打开数据库判断用户是否存在,info为表名,username为字段名
set rsc=server.createobject("adodb.recordset")
sqlc="select * from info where username='"request.Form("username")"' and password='"request.Form("password")"'"
rsc.open sqlc,conn,1,1
session("username")=rsc("username")
session("password")=rsc("password")
session.Timeout=30
set rsc=nothing
response.Redirect("change.asp")
'如果用户不存在,session("username")为空
%
3,(change.asp 用户信息修改页面)
!-- #include file="conn.asp" --
html
head
meta http-equiv="Content-Type" content="text/html; charset=gb2312"
title修改/title
style type="text/css"
!--
body,td,th {
font-size: 14px;
}
--
/style/head
center
body
br
%
set rsc=server.createobject("adodb.recordset")
sqlc="select * from info where username='"session("username")"' and password='"session("password")"'"
rsc.open sqlc,conn,1,1
nr=rsc("password")
username=rsc("username")
password=rsc("password")
sex=rsc("sex")
qq=rsc("qq")
mail=rsc("mail")
add=rsc("add")
personalinfo=rsc("personalinfo")
vv=rsc("ntime")
set rsc=nothing
if nr="" then
response.Redirect("index.asp")
end if
if strcomp(nr,request.Form("password"))=0 then
response.Write("欢迎你!"request.Form("username"))
response.Write("你是在"vv"注册的")
session("username")=request.Form("username")
end if
if session("username")="" then
response.Redirect("index.asp")
end if
%
form name="form1" method="post" action="change.asp?ac=ch"
table width="39%" height="105" border="0"
tr
td width="27%" height="30"用户名:/td
td width="73%" height="30"input name="username" type="text" id="username" value="%=username%"
*/td
/tr
tr
td height="30"密 码:/td
td height="30"input name="password" type="text" id="password" value="%=password%"
*/td
/tr
tr
td height="30"性 别:/td
td height="30"input name="sex" type="text" id="sex" value="%=sex%"/td
/tr
tr
td height="30"QQ:/td
td height="30"input name="qq" type="text" id="qq" value="%=qq%"/td
/tr
tr
td height="30"Mail:/td
td height="30"input name="mail" type="text" id="mail" value="%=mail%"/td
/tr
tr
td height="30"地 址:/td
td height="30"input name="add" type="text" id="add" value="%=add%"/td
/tr
tr
td介绍/td
tdtextarea name="personalinfo" cols="30" rows="6" id="personalinfo"%=personalinfo%/textarea/td
/tr
tr
td /td
tdinput type="submit" name="Submit" value="修改"
a href="change.asp?se=y" target="_self"退出系统/a/td
% if strcomp(request.QueryString("se"),"y")=0 then
session("username")=""
response.Redirect("index.asp")
end if
%
/tr
/table
/form
%
if strcomp(request.QueryString("ac"),"ch")=0 then
set rs=server.createobject("adodb.recordset")
sql="select * from info where username='"session("username")"'"
rs.open sql,conn,1,3
rs("username")=request.Form("username")
rs("password")=request.Form("password")
rs("mail")=request.Form("mail")
rs("sex")=request.Form("sex")
rs("qq")=request.Form("qq")
rs("add")=request.Form("add")
rs("personalinfo")=request.Form("personalinfo")
rs.update
set rs=nothing
response.Write("修改完成!")
end if
%
/body
/center
/html
4,(reg.asp 新用户注册页面)
html
head
meta http-equiv="Content-Type" content="text/html; charset=gb2312"
title用户注册/title
style type="text/css"
!--
body,td,th {
font-family: 宋体;
font-size: 14px;
}
--
/style
/head
body
center
用户注册br
%
=request.QueryString("msg")
%
form name="form1" method="post" action="addnewdata.asp?ac=adduser"
table width="39%" height="105" border="0"
tr
td width="27%" height="30"用户名:/td
td width="73%" height="30"input name="username" type="text" id="username"
*/td
/tr
tr
td height="30"密码:/td
td height="30"input name="password" type="password" id="password"
*/td
/tr
tr
td height="30"确定密码:/td
td height="30"input name="password2" type="password" id="password2"
*/td
/tr
tr
td height="30"性别:/td
td height="30"input name="sex" type="text" id="sex"/td
/tr
tr
td height="30"QQ:/td
td height="30"input name="qq" type="text" id="qq"/td
/tr
tr
td height="30"Mail:/td
td height="30"input name="mail" type="text" id="mail"/td
/tr
tr
td height="30"地址:/td
td height="30"input name="add" type="text" id="add"/td
/tr
tr
td个人介绍/td
tdtextarea name="personalinfo" cols="30" rows="6" id="personalinfo"/textarea/td
/tr
tr
td /td
tdinput type="submit" name="Submit" value="提交"/td
/tr
/table
/form
/center
/body
/html
5,(addnewdata.asp 新用户注册数据处理文件)
!-- #include file="conn.asp" --
html
head
meta http-equiv="Content-Type" content="text/html; charset=gb2312"
title成功/title
/head
body
%
ac=request.QueryString("ac")
msg="注册错误信息"
if request.Form("username")="" then
msg=msg"br""用户名不能为空"
end if
if strcomp(cstr(request.Form("password")),cstr(request.Form("password2")))0 then
msg=msg"br""两次密码输入不同"
end if
if len(request.Form("password"))6 then
msg=msg"br""密码太简单"
end if
if strcomp(msg,"注册错误信息")0 then
response.Redirect("reg.asp?msg="msg)
end if
if ac="adduser" then
set rsc=server.createobject("adodb.recordset")
sql="select * from info where username='"request.Form("username")"'"
rsc.open sql,conn,1,1
ck=rsc("username")
set rsc=nothing
if ck"" then
msg=msg"br""用户名被人注册"
response.Redirect("reg.asp?msg="msg)
end if
dsql="select * from info where id is null"
set rs=server.createobject("adodb.recordset")
rs.open dsql,conn,1,3
rs.addnew
rs("username")=request.Form("username")
rs("password")=request.Form("password")
rs("mail")=request.Form("mail")
rs("sex")=request.Form("sex")
rs("qq")=request.Form("qq")
rs("add")=request.Form("add")
rs("personalinfo")=request.Form("personalinfo")
rs("ntime")=now
rs.update
set rs=nothing
%
center
a href="index.asp" target="_self"注册成功,点击登陆/a
/center
%
end if
%
/body
/html
6,(conn.asp 数据库连接文件)
%
'连接数据库开始
dim conn,rs,sql
on error resume next
dbpath=server.mappath("userinfo.mdb")
set conn=server.createobject("adodb.connection")
conn.open "PROVIDER=Microsoft.jet.OLEDB.4.0;data source="dbpath
'创建记录对象
set rs=server.createobject("adodb.recordset")
%
7,(userinfo.mdb ACCESS 数据库)
在ACCESS中建一个表,然后在这个表中建立字段名称
表名:info
字段名称 数据类型
id 自动编号
username 文本
password 文本
sex 文本
quest 文本
qq 文本
mail 文本
personalinfo 文本
ntime 文本
登录系统asp源代码的介绍就聊到这里吧,感谢你花时间阅读本站内容,更多关于、登录系统asp源代码的信息别忘了在本站进行查找喔。
版权说明:如非注明,本站文章均为 AH站长 原创,转载请注明出处和附带本文链接;
- 上一篇:asp网页查询代码(asp查询表)
- 下一篇:qq秀源代码(手机源代码)
相关推荐
- 04-18crm系统(crm系统有哪些品牌)
- 04-18卡一卡二卡四卡视频免费观看的简单介绍
- 04-18网页设计源代码模板(网页设计源代码模板怎么用)
- 04-18晚上正能量网址免费安全的简单介绍
- 04-18大连网站制作的简单介绍
- 04-18seo定义(seo定义及基本介绍)
- 04-18淮北网站建设的简单介绍
- 04-18免费网页在线客服系统(免费网页在线客服系统手机)
- 04-18简单的网页制作(简单的网页制作流程)
- 04-18百度推广登录入口(百度推广登录入口官网高清在线观看)
取消回复欢迎 你 发表评论:
- 标签列表
- 最近发表
- 友情链接