当前位置:首页 > 代码 > 正文

简单登录系统asp源代码的简单介绍

admin 发布:2022-12-19 19:33 132


今天给各位分享简单登录系统asp源代码的知识,其中也会对进行解释,如果能碰巧解决你现在面临的问题,别忘了关注本站,现在开始吧!

本文目录一览:

用ASP制作登陆页面的代码

时间关系,没给你写 所以就复制了一段 可到我论坛看看

代码如下:

1.connection.asp里的代码是:

%

set conn=server.createobject("adodb.connection")

conn.open "provider=microsoft.jet.oledb.4.0;data source="server.MapPath("student.mdb")

%

2.yanzheng.asp里的代码是:

!--#include file="connection.asp"--

%

dim zhanghao,mima

zhanghao=request("zhanghao")

mima=request("mima")

if zhanghao="" then

%

script language=javascript

alert("帐号为空");

location.href="denglu.asp"

/script

% end if %

% if mima="" then

%

script language=javascript

alert("密码为空");

location.href="denglu.asp"

/script

% end if %

%set rs=server.createobject("adodb.recordset")

rs.open "select * from student where zhanghao='"zhanghao"'",conn,1,3

if not rs.eof then

if mima=rs("mima") then

session("zhanghao")=zhanghao

Response.write("scriptlocation.href('index.asp')/script" )

else

response.write ("scriptalert('用户密码错误');location.href('denglu.asp')/script")

end if

end if

if rs.eof then

response.write ("scriptalert('用户帐号错误');location.href('denglu.asp')/script")

end if

set rs=nothing

rs.close

%

二、

conn.asp

%

Set conn=Server.CreateObject("ADODB.Connection")

connstr="DBQ="+server.mappath("haha.mdb")+";DefaultDir=;DRIVER={Microsoft Access Driver (*.mdb)}"

conn.Open connstr

%

index.asp

%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%

!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" ""

html

head

meta http-equiv="Content-Type" content="text/html; charset=gb2312"

title无标题文档/title

/head

body

form name="form1" method="post" action="login.asp"

table width="50%" height="108" border="0" cellpadding="0" cellspacing="0"

tr

td用户名:/td

tdinput name="us" type="text" id="us"/td

/tr

tr

td密码:/td

tdinput name="pa" type="password" id="pa" value=""/td

/tr

tr

td /td

tdinput type="submit" name="Submit" value="提交"/td

/tr

/table

/form

/body

/html

login.asp

!--#include file="conn.asp"--

%

us=replace(request.form("us"),"'","’")

pa=replace(request.form("pa"),"'","’")

%

%

set rs=server.createobject("adodb.recordset")

sql="select * from haha where us='"us"' and pa='"pa"'"

rs.open sql,conn,1,1

%

%

if rs.eof or rs.bof then

response.write"密码错误~"

else

response.redirect"main.asp"

end if

%

三、

连接数据库(conn.asp)

%

dim db,conn,connstr

db="@data.mdb"

set Conn = server.CreateObject("ADODB.Connection")

connstr="provider=microsoft.jet.oledb.4.0;data source=" server.MapPath("../data/"db"")

conn.Open connstr

%

登录页面(login.asp)

% @language=vbscript %

!--#include file="conn.asp"--

%

On Error Resume Next

dim uid

dim pwd

uid=trim(request.Form("uid")) '获得用户名

pwd=trim(request.form("pwd")) '获得密码

dim rs

set rs=server.createobject("adodb.recordset")

if uid"" then

dim sqlstr

sqlstr="select uid,pwd from admin where uid='"replace(uid,"'","''")"' and pwd='"replace(pwd,"'","''")"'"

rs.open sqlstr,conn,3,1

if not rs.eof then

session("uid")=uid

response.redirect "login_ok.asp" '重定位url

else

response.redirect "error.htm"

end if

else

response.redirect "error.htm"

end if

%

ASP.NET简单的登录 求代码

table

tr

td

asp:Label ID="Label1" runat="server" Text="账号:"/asp:Label/td

td

asp:TextBox ID="txtUserName" runat="server"/asp:TextBox/td

/tr

tr

td

asp:Label ID="Label2" runat="server" Text="密码:"/asp:Label/td

tdasp:TextBox ID="txtPwd" runat="server" TextMode="Password"/asp:TextBox/td

/tr

tr

td style="text-align:center" colspan="2"

asp:Button ID="btnSubmits" runat="server" Text="登录"

onclick="btnSubmit_Click" /

/td

/tr

/table

后台btnSubmit_Click事件

using (SqlConnection sc = new SqlConnection("Data Source=.;Initial Catalog=Test;User ID=sa;Password=yx19891126;"))

{

sc.Open();

string UserName = txtUserName.Text.Trim();

string Password = txtPwd.Text.Trim();

using (SqlCommand cmd = new SqlCommand("select * from Users where UserName='"+UserName+"' Password='"+Password+"'",sc))

{

if (cmd.ExecuteNonQuery() 0)

Response.Write("scriptalert('登录成功');/script");

else

Response.Write("scriptalert('登录失败');/script");

}

}

这是最简单的判断,一些小细节直接忽略了,你可以稍微改改让登录功能更完善

求asp登陆代码

!-- #include file="web.config.asp" --

!-- #include file="include/ClsMain.asp" --

!-- #include file="include/md5.asp" --

%

Dim myCls,uUserName,uPwd,uChkCode,tmpRs

Set myCls = new ClsMain

if Request.QueryString("Mark")"UserLogOut" then

if IsArray(Session("KS_CRM")) then

Session("KS_CRM") = null

Response.Redirect("Index.asp")

end if

end if

If Request.QueryString("Mark")="UserLogOut" then

Session("KS_CRM")=""

End if

If Request.QueryString("Mark")="UserLogin" then

uChkCode=myCls.delUrlSqlin(Request.Form("uChkCode"))

if uChkCodeSession("GetCode") then myCls.Error("登陆失败:\n\n验证码错误,请返回重新输入验证码")

uUserName=myCls.delUrlSqlin(Request.Form("uUserName"))

uPwd=myCls.delUrlSqlin(Request.Form("uPwd"))

if uUserName="" or uPwd="" then myCls.Error("登陆失败:\n\n用户名和密码都不能为空!")

set tmpRs = mycls.CreateRs("select ID,UserRealName,LastLoginTime,LastLoginIP,GroupID from KS_User where UserLoginName='"uUserName"' and UserLoginPWD='"md5(uPwd)"'",1,3)

if err0 then myCls.Error("登陆失败:\n\n程序检测到在登陆过程中至少有一个异常发生\n登陆被取消")

if tmpRs.eof and tmpRs.bof then

myCls.Error("登陆失败:\n\n用户名或密码错误!")

else

Dim TmpArr(4)

TmpArr(0) = tmpRs(0)

TmpArr(1) = uUserName

TmpArr(2) = tmpRs(1)

TmpArr(3) = md5(uPwd)

TmpArr(4) = tmpRs(4)

Session("KS_CRM") = TmpArr

tmpRs(2) = Now()

tmpRs(3) = mycls.GetIP()

tmpRs.update

tmpRs.Close

set tmpRs=Nothing

If Not(mycls.ChkPower(1,0)) Then

mycls.Error("登陆失败:\n\n您所在组不具备登陆系统权限!")

Else

response.Redirect("Index.asp")

End If

end if

End if

%

上面是我写的登陆代码/原理自己看哈。。我想没有多少人会为了10分给你详细讲的~myCls是我写的一个类。。具体怎么样你可以不用了解。。你只需要知道如何实现登陆就行了~

asp登陆系统源代码

form id="form1" name="form1" method="post" action="UserLogin.asp"

你这个里面调用的

UserLogin.asp登陆处理程序呢?

asp登录界面源代码

default

html

head

meta http-equiv="Content-Language" content="zh-cn"

meta http-equiv="Content-Type" content="text/html; charset=gb2312"

meta name="GENERATOR" content="Microsoft FrontPage 4.0"

meta name="ProgId" content="FrontPage.Editor.Document"

title个人注册/title

script language=vbscript

sub b1_onclick()

if len(trim(form1.t1.value))=0 then

msgbox"请输入你的帐号!",0+48,"提示"

form1.t1.focus

elseif len(trim(form1.t2.value))=0 then

msgbox"请输入你的密码!",0+48,"提示"

form1.t2.focus

else

if isnumeric(form1.t1.value)=true then

msgbox"请输入汉字!",0+48,"重输"

form1.t1.focus

elseif len(trim(form1.t2.value))3 or len(trim(form1.t2.value))8 then

msgbox"密码在3至8位之间!",0+48,"重输"

form1.t2.focus

else

window.open"1.asp","new","toolbar=no,width=280,height=150,menubar=no,scrollbar=no,resizable=0"

form1.submit

end if

end if

end sub

/script

/head

body

pyw9sky天地/p

form method="POST" action="1.asp" name="form1" target="new"

p align="center"font size="6" color="#FF0000" face="隶书"个人注册/font/p

p align="center"font size="4"姓名:/fontinput type="text" name="t1" size="20"/p

p align="center"font size="4"密码:/fontinput type="password" name="t2" size="20"/p

p align="center"input type="button" value="注册" name="B1"input type="reset" value="重写" name="B2"/p

/form

/body

/html

1.asp

%@ language=vbscript %

%

dim x,y,num

num=0

x=request.form("t1")

y=request.form("t2")

response.cookies("user")("name")=x

response.cookies("user")("num")=num

response.cookies("user")("password")=y

response.cookies("user").expires=date()+365

%

html

head

title信息确认/title

/head

body

pyw9sky天地/p

table border="0" width="100%" id="table1" align=center cellspacing=1 bgcolor=#333399

tr bgcolor=#ffffff align=center

td colspan="2" width="100%"信息确认/td

/tr

tr bgcolor=#ffffff align=center

td width="31%"姓名:/td

td width="69%"% = x %/td

/tr

tr bgcolor=#ffffff align=center

td width="31%"密码:/td

td width="69%"% = y %/td

/tr

tr bgcolor=#ffffff align=center

td colspan="2" width="100%" align="center"a target="_blank" href="2.asp"登录/a

font onclick="window.close()" style="cursor:hand"关闭/font/td

/tr

/table

/body

/html

%@ language=vbscript %

html

head

title个人登录/title

script language=vbscript

sub b1_onclick()

if len(trim(form1.t1.value))=0 then

msgbox"请输入你的姓名!",0+48,"提示"

form1.t1.focus

elseif len(trim(form1.t2.value))=0 then

msgbox"请输入你的密码!",0+48,"提示"

form1.t2.focus

else

if isnumeric(form1.t1.value)=true then

msgbox"请输入汉字!",0+48,"重输"

form1.t1.focus

elseif len(trim(form1.t2.value))3 or len(trim(form1.t2.value))8 then

msgbox"密码在3至8位之间!",0+48,"重输"

form1.t2.focus

else

form1.submit

end if

end if

end sub

/script

/head

body

form method="POST" action="3.asp" name="form1" target="_blank"

p align="center"font size="6" color="#FF0000" face="隶书"个人登录/font/p

p align="center"font size="4"姓名;/fontinput type="text" name="t1" size="20"/p

p align="center"font size="4"密码:/fontinput type="password" name="t2" size="20"/p

p align="center"input type="button" value="开始登录" name="B1"input type="reset" value="重新输入" name="B2"/p

/form

/body

/html

3.asp

% @ language=vbscript %

%

dim x,y,nm,pw

x=request.form("t1")

y=request.form("t2")

nm=requset.cookies("user")("name")

pw=requset.cookies("user")("password")

if nmx or pwy then

response.redirect"default.htm"

end if

%

%

dim num

num=request.cookies('user")("num")

if num=0 then

num=1

else

num=num+1

end if

response.cookies("user")("num")=num

%

html

head

title欢迎来访yw9sky/title

/head

body

欢迎% =nm %第% =num %次登录

/body

/html

关于简单登录系统asp源代码和的介绍到此就结束了,不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站。

版权说明:如非注明,本站文章均为 AH站长 原创,转载请注明出处和附带本文链接;

本文地址:http://ahzz.com.cn/post/20703.html


取消回复欢迎 发表评论:

分享到

温馨提示

下载成功了么?或者链接失效了?

联系我们反馈

立即下载