JSP SQL实现用户登录与注册.docx

上传人:b****6 文档编号:7183390 上传时间:2023-01-21 格式:DOCX 页数:18 大小:20.74KB
下载 相关 举报
JSP SQL实现用户登录与注册.docx_第1页
第1页 / 共18页
JSP SQL实现用户登录与注册.docx_第2页
第2页 / 共18页
JSP SQL实现用户登录与注册.docx_第3页
第3页 / 共18页
JSP SQL实现用户登录与注册.docx_第4页
第4页 / 共18页
JSP SQL实现用户登录与注册.docx_第5页
第5页 / 共18页
点击查看更多>>
下载资源
资源描述

JSP SQL实现用户登录与注册.docx

《JSP SQL实现用户登录与注册.docx》由会员分享,可在线阅读,更多相关《JSP SQL实现用户登录与注册.docx(18页珍藏版)》请在冰豆网上搜索。

JSP SQL实现用户登录与注册.docx

JSPSQL实现用户登录与注册

用户登陆与注册系统

系统介绍:

本系统提供用户登陆与确认

数据库表:

custom(id,uid,password.gender.username等)

数据源名称:

try

实现原理:

JSP+SQL2000

Index.jsp

<%@pagecontentType="text/html;charset=gb2312"language="java"errorPage=""%>

DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Transitional//EN""http:

//www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

//www.w3.org/1999/xhtml">

登陆

--

.STYLE2{

font-size:

24px;

font-family:

"宋体";

font-weight:

bold;

color:

#FF0000;

}

.STYLE3{

font-family:

"新宋体";

font-size:

16px;

}

.STYLE4{color:

#FF0000}

.STYLE5{

font-size:

12px;

line-height:

14px;

text-decoration:

none;

}

-->

 

用户登陆

用户名:

密 码:

注册新用户

Logon.jsp

<%@pagecontentType="text/html;charset=gb2312"language="java"import="java.sql.*"errorPage=""%>

DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Transitional//EN""http:

//www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

//www.w3.org/1999/xhtml">

登陆确认

functionBackWard()

{

history.back();

}

--

.STYLE2{

font-size:

24px;

font-family:

"宋体";

font-weight:

bold;

color:

#FF0000;

}

.STYLE3{

font-family:

"新宋体";

font-size:

16px;

}

.STYLE4{color:

#FF0000}

.STYLE5{

font-size:

12px;

line-height:

14px;

text-decoration:

none;

}

-->

<%

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

Stringdriver="jdbc:

odbc:

try";

Connectionconn=DriverManager.getConnection(driver);

Statementstmt=conn.createStatement();

booleana;

Stringuid=request.getParameter("uid");

Stringpassword=request.getParameter("password");

Stringsql="select*fromcustomwhereuid='"+uid+"'andpassword='"+password+"'";

ResultSetrs=stmt.executeQuery(sql);

a=rs.next();

if(a==false)

{rs.close();

session.setAttribute("uid",uid);

%>

:

)欢迎您<%=uid%>

<%}

else

{

rs.close();

%>

输入错误,请重新填写!

<%}%>

Logoff.jsp

<%@pagecontentType="text/html;charset=gb2312"language="java"import="java.sql.*"errorPage=""%>

DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Transitional//EN""http:

//www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

//www.w3.org/1999/xhtml">

用户注销

--

.STYLE2{

font-size:

24px;

font-family:

"宋体";

font-weight:

bold;

color:

#FF0000;

}

.STYLE3{

font-family:

"新宋体";

font-size:

16px;

}

.STYLE4{color:

#FF0000}

.STYLE5{

font-size:

12px;

line-height:

14px;

text-decoration:

none;

}

-->

 

成功注销!


5秒后自动返回首页,如果你不想等待,可以点击这里返回首页

<%response.setHeader("Refresh","5;URL=index.jsp");%>

Register.jsp

<%@pagecontentType="text/html;charset=gb2312"language="java"import="java.sql.*"errorPage=""%>

DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Transitional//EN""http:

//www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

//www.w3.org/1999/xhtml">

用户注册

--

.STYLE2{

font-size:

24px;

font-family:

"宋体";

font-weight:

bold;

color:

#FF0000;

}

.STYLE3{

font-family:

"新宋体";

font-size:

16px;

}

.STYLE4{color:

#FF0000}

.STYLE5{

font-size:

12px;

line-height:

14px;

text-decoration:

none;

}

-->

--

functionCheckSubmit()

{

if(document.registerform.uid.value=="")

{alert("请输入用户名!

");document.registerform.uid.focus();returnfalse;}

if(document.registerform.password.value=="")

{alert("请输入密码!

");document.registerform.password.focus();returnfalse;}

if(document.registerform.password2.value=="")

{alert("请验证密码!

");document.registerform.password2.focus();returnfalse;}

if(document.registerform.password2.value!

=document.registerform.password.value)

{alert("密码验证出错!

");document.registerform.password.focus();returnfalse;}

if(document.registerform.username.value=="")

{alert("请输入真实姓名!

");document.registerform.username.focus();returnfalse;}

returntrue;

}

请如实填写下面的注册申请单(*为必填项)

用户ID:

*

密   码:

*

验证密码:

*

真实姓名:

*

性   别:

*

Register1.jsp

<%@pagecontentType="text/html;charset=gb2312"language="java"import="java.sql.*"errorPage=""%>

DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Transitional//EN""http:

//www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

//www.w3.org/1999/xhtml">

注册信息确认

--

.STYLE2{

font-size:

24px;

font-family:

"宋体";

font-weight:

bold;

color:

#FF0000;

}

.STYLE3{

font-family:

"新宋体";

font-size:

16px;

}

.STYLE4{color:

#FF0000}

.STYLE5{

font-size:

12px;

line-height:

14px;

text-decoration:

none;

}

-->

functionbackward()

{

history.back();

}

<%

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

Stringdriver="jdbc:

odbc:

try";

Connectionconn=DriverManager.getConnection(driver);

Statementstmt=conn.createStatement();

Stringuid=request.getParameter("uid");

Stringsql="select*fromcustomwhereuid='"+uid+"'";

ResultSetrs=stmt.executeQuery(sql);

if(rs.next())

{

rs.close();

stmt.close();

conn.close();

%>

用户名不能重名,请重新选择!

<%}

else{

rs.close();

Stringusername=request.getParameter("username");

Stringgender=request.getParam

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 高等教育 > 研究生入学考试

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1