×

asp登录源代码

asp登录源代码(asp.net登录代码)

admin admin 发表于2023-10-26 01:31:47 浏览32 评论0

抢沙发发表评论

本文目录

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=“http://schemas.microsoft.com/intellisense/ie5“》《/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 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登陆界面的源码

《%dim db,conn,connstrdb=“数据库路劲“set Conn = server.CreateObject(“ADODB.Connection“)connstr=“provider=microsoft.jet.oledb.4.0;Persist Security Info=False;data source=“ & server.MapPath(db)conn.Open connstrIF Request(“action“)=“login“ Then verifycode=cstr(request(“verifycode“)) if cstr(session(“verifycode“))《》verifycode then session(“verifycode“)=““ Response.Write(“《script language=javascript》alert(’请输入正确的认证码!’);this.location.href=’login.asp’;《/script》“) Response.End else session(“verifycode“)=““ end if user=replace(trim(request.form(“uName“)),“’“,“’’“) password=replace(trim(request.form(“Password“)),“’“,“’’“) if instr(user,“%“) or instr(user,“#“) or instr(user,“?“) or instr(user,“|“) or instr(user,“’“) then response.write “《script language=javascript》alert(’您的姓名含有非法字符!’);this.location.href=’login.asp’;《/script》“ response.end end if if instr(password,“%“) or instr(password,“#“) or instr(password,“?“) or instr(password,“|“) then response.write “《script language=javascript》alert(’您的密码含有非法字符!’);this.location.href=’login.asp’;《/script》“ response.end end if uName=Trim(Request.Form(“uName“)) Password=Trim(Request.Form(“Password“)) IF uName《》““ And Password《》““ Then SQL=“Select * From adminname Where adminname=’“& uName &“’“ Set RS=Server.CreateObject(“ADODB.REcordset“) RS.Open SQL,Connstr,1,3 IF Not RS.Eof Then IF Password=RS(“adminpassword“) Then if rs(“jb“)=“高级管理员“ then Session(“cwz_youth1710“)=uName Session(“cwz_youth1710_zj“)=uName Session(“cwz_youth1710_dj“)=uName rs(“LoginTimes“)=rs(“LoginTimes“)+1 rs(“LoginTime“)=now() rs(“LoginIP“)=Request.ServerVariables(“REMOTE_ADDR“) rs.Update Response.Redirect “index.asp“ elseif rs(“jb“)=“中级管理员“ then Session(“cwz_youth1710_zj“)=uName Session(“cwz_youth1710_dj“)=uName rs(“LoginTimes“)=rs(“LoginTimes“)+1 rs(“LoginTime“)=now() rs(“LoginIP“)=Request.ServerVariables(“REMOTE_ADDR“) rs.Update Response.Redirect “index.asp“ elseif rs(“jb“)=“低级管理员“ then Session(“cwz_youth1710_dj“)=uName rs(“LoginTimes“)=rs(“LoginTimes“)+1 rs(“LoginTime“)=now() rs(“LoginIP“)=Request.ServerVariables(“REMOTE_ADDR“) rs.Update Response.Redirect “index.asp“ end if else response.write(“《script language=javascript》alert(’密码错误!’);this.location.href=’login.asp’;《/script》“) response.end End IF else response.write(“《script language=javascript》alert(’用户名不存在!’);this.location.href=’login.asp’;《/script》“) response.end End IF else response.write(“《script language=javascript》alert(’用户名或密码不能为空!’);this.location.href=’login.asp’;《/script》“) End IFEnd IF Function getcode1() Dim test On Error Resume Next Set test=Server.CreateObject(“Adodb.Stream“) Set test=Nothing If Err Then Dim zNum Randomize timer zNum = cint(8999*Rnd+1000) Session(“verifycode“) = zNum getcode1= Session(“verifycode“) Else getcode1= “《img src=““getcode.asp““》“ End If End Function %》《html》《head》《meta http-equiv=“Content-Type“ content=“text/html; charset=gb2312“》《title》韶关学院50周年校庆网站后台管理登陆页面《/title》《style type=“text/css“》《!--body { margin-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px;}body,td,th { font-size: 12px;}--》《/style》《/head》《body》《div align=“center“》 《table width=“770“ border=“0“ cellspacing=“0“ cellpadding=“0“》 《tr》 《td height=“486“》 《div align=“center“》 《form action=“login.asp?action=login“ method=“post“》 《table width=“300“ border=“0“ cellspacing=“0“ cellpadding=“0“》 《tr》 《td width=“88“ height=“30“》《div align=“right“》用户名:《/div》《/td》 《td colspan=“2“》《input type=text name=“uName“ size=12 maxlength=20 style=“background-attachment: scroll; background-repeat: repeat; font-size: 9pt; height: 18; width: 102; background-color: #FFFFFF; border: 1 solid #000000; background-position: none 0%“》《/td》 《/tr》 《tr》 《td height=“30“》《div align=“right“》密 码:《/div》《/td》 《td height=“18“ colspan=“2“》《input type=password name=“Password“ size=12 maxlength=16 style=“background-attachment: scroll; background-repeat: repeat; font-size: 9pt; height: 18; width: 102; background-color: #FFFFFF; border: 1 solid #000000; background-position: none 0%“》《/td》 《/tr》 《tr》 《td height=“30“》《div align=“right“》认证码:《/div》《/td》 《td width=“112“ height=“30“》《input class=“input“ type=“text“ name=“verifycode“ size=“20“ style=“background-attachment: scroll; background-repeat: repeat; font-size: 9pt; height: 18; width: 102; background-color: #FFFFFF; border: 1 solid #000000; background-position: none 0%“》《/td》 《td width=“100“》《%=getcode1()%》《/td》 《/tr》 《tr》 《td height=“30“ colspan=“3“》《div align=“center“》《font color=“#000000“》 《input type=submit value=’ 提 交 ’ name=Submit style=“background-color: #DDDDDD; background-repeat: repeat; background-attachment: scroll; font-size: 9pt; height: 20; width: 50; border: 1px groove #000000; background-position: 0% 50%“》 《input type=reset value=’ 取 消 ’ name=Submit style=“background-color: #DDDDDD; background-repeat: repeat; background-attachment: scroll; font-size: 9pt; height: 20; width: 50; border: 1px groove #000000; background-position: 0% 50%“》 《/font》《/div》《/td》 《/tr》 《/table》 《/form》 《/div》《/td》 《/tr》 《/table》《/div》《/body》《/html》

求记住登录状态的源代码(ASP)

很简单,用cookies记录,先写进cookies,用以下语句response.cookies(“username“)=usernameresponse.cookies(“password“)=passwordresponse.cookies(“username“).expire=now+1response.cookies(“password“).expire=now+1后两句是设置了cookies的时间记忆期限,这里是记住一天,你想要多长时间都可以自己设置.然后在每个页面中只要读取就行了.读取用request.cookies(“username“)和response.cookies(“password“)

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.focuselse 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 ifend ifend sub《/script》《/head》《body》《p》yw9sky天地《/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“》姓名:《/font》《input type=“text“ name=“t1“ size=“20“》《/p》 《p align=“center“》《font size=“4“》密码:《/font》《input 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》《p》yw9sky天地《/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.focuselse 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 ifend ifend 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“》姓名;《/font》《input type=“text“ name=“t1“ size=“20“》《/p》 《p align=“center“》《font size=“4“》密码:《/font》《input 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 nm《》x or pw《》y then response.redirect“default.htm“ end if%》《%dim numnum=request.cookies(’user“)(“num“)if num=0 then num=1else num=num+1end ifresponse.cookies(“user“)(“num“)=num%》《html》《head》 《title》欢迎来访yw9sky《/title》《/head》《body》欢迎《% =nm %》第《% =num %》次登录《/body》《/html》

学生选课系统登录的源代码(asp+access)要怎么写

string ls_uname,ls_pwd1,ls_pwd2,ls_sno,ls_s1 ls_uname=sle_userid.text ls_pwd1=sle_password.text select userName into :ls_sno from userTB where userName=:ls_uname; if sle_userid.text=““ or sle_password.text=““ then messagebox(“提示“,“用户名或密码不能为空,请输入用户名或密码!“) //sle_userid.text=““ //sle_password.text=““ return end if select password into :ls_pwd2 from userTB where userName = :ls_uname ; //sle_1.text=ls_sno//sle_2.text=ls_pwd2if ls_pwd1 = ls_pwd2 then open(w_main) close(w_login) else messagebox(“错误“,“用户名或密码错误,请重新输入!“) sle_password.text=““ return end if 大概的形式就是这样的

asp用户登陆源代码及处理页面代码

你把登录的form的action指向一个asp文件,如check.asp。那么这个文件的内容如下:(注:data.mdb是你的数据库所在目录,login.asp是你成功登录以后所指向的页面,user是数据库里的一个表;表里要有username和password两个字段。)《%set conn=Server.Createobject(“adodb.connection“)adoconn.Open“Driver={Microsoft Access Driver(*.mdb)};DBQ=“& _Server.MapPath(“data.mdb“)username=request.form(“usename“)password=request.form(“password“)if username=““ or password=““ thenresponse.write (“《script language=javascript》alert’用户名和密码不能为空!’;history.go(-1);《/script》“)elseset rs=Createobject(“adodb.connection“)sql=“select * from user“rs.open.sql conn,1,3if username=rs(“username“) and password=rs(“password“) thenresponse.redirct “login.asp“elseresponse.write (“《script language=javascript》alert’用户名或密码输入错误,请确认!’;history.go(-1);《/script》“)%》《%end if%》《%end if%》《%rs.closeset rs=nothingconn.closeset conn=nothing%》差不多就这样了。你自己去调试吧。可能有些单词写错了。哈哈。不好意思。如果行就多给点分吧。