用html和jsp实现网站的登陆功能
来源:互联网 发布:郭敬明 梦里花落知多少 编辑:程序博客网 时间:2024/05/19 02:43
显示界面 login.html
<html >
<head>
<meta http-equiv="Content-Type" content="text/html; charset=GB2312" />
<title>登陆</title>
</head>
<body>
<center>
<form action="http://127.0.0.1:8080/DB/login.jsp" method="post">
用户名:<input type="text" maxlength="20" size="20" id="muser" name="muser">
<br>
密码:<input type="password" maxlength="20" size="20" id="passwd" name="passwd">
<br>
<input type="submit" value="登陆" id="mlogin" name="mlogin">
<input type="reset" value="重置" id="mre" name="mre">
</form>
<br>
<a href="#">忘记密码?</a> <a href="protocol.html">立即注册</a>
</center>
</body>
</html>
登陆提交到的jsp页面login.jsp
<%@ page contentType="text/html" language="java" import="java.sql.*" errorPage="" pageEncoding="GB2312"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=GB2312" />
<meta http-equiv="Expires" content="0">
<meta http-equiv="kiben" content="no-cache">
<title>登录验证</title>
<%
request.setCharacterEncoding("GB2312");//设置请求的编码格式为GB2312
//开始连接数据库
String Suser = request.getParameter("muser");
String Spasswd = request.getParameter("passwd");
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver").newInstance();
Connection conn = DriverManager.getConnection("jdbc:sqlserver://localhost:1433;DatabaceName=ProjManagerPlatform", "sa", "100862");
Statement stmt = conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY);
try{
ResultSet rs;
rs = stmt.executeQuery("select userName from ProjManagerPlatform.dbo.UsersInfo where userName='"+Suser+"'");//查询语句
if(rs.next()){
Suser = rs.getString("userName"); //得到userName在数据库中的值
}else{
rs.close();
stmt.close();
conn.close();
%>
<!--window.location.href = "login.html"是跳转到login.html页面-->
<script language="javascript" type="text/javascript">alert("用户名不存在!");window.location.href = "login.html"</script>
<%
}
rs = stmt.executeQuery("select password from ProjManagerPlatform.dbo.UsersInfo where userName='"+Suser+"'");
rs.next();
Spasswd = rs.getString("password"); //得到password在数据库中的值
if(request.getParameter("passwd").equals(Spasswd)){
rs.close();
stmt.close();
conn.close();
%>
<!--window.location.href = "indexm.htm"登陆成功跳转到主页面-->
<script language="javascript" type="text/javascript">window.location.href = "indexm.htm"</script>
<%
}else{
rs.close();
stmt.close();
conn.close();
%>
<script language="javascript" type="text/javascript">alert("用户密码错误!");window.location.href = "login.html"</script>
<%
}
}
catch(Exception e){
out.println(e.getMessage());
}
%>
</head>
<body>
</body>
</html>
- 用html和jsp实现网站的登陆功能
- JSP的登陆验证功能实现
- python实现网站登陆功能
- jsp/html简单的打印功能实现
- 使用jsp实现网站计数的功能
- jsp+servlet实现最基本的注册登陆功能
- jsp+servlet实现最基本的注册登陆功能
- jsp+servlet实现最基本的注册登陆功能
- jsp+servlet实现最基本的注册登陆功能
- jsp+servlet实现最基本的注册登陆功能
- jsp+servlet实现最基本的注册登陆功能
- JSP登陆的实现
- 用SharedPreferences实现账号密码的记忆功能和自动登陆功能
- JSP页面和HTML页面的区别和功能
- jsp页面和html页面的区别和功能
- 关于html和jsp中锚点的实现
- 关于html和jsp中锚点的实现
- 用jsp+javabean实现用户注册和查看的功能
- Java基础<三>---> 流程控制与函数
- 【Visual C++】游戏开发笔记四十五 浅墨DirectX教程十三 深度测试和Z缓存专场
- C/C++程序员必须熟练应用的开源项目
- 举例介绍 C++高质量编程
- ASP.NET MVC 入门介绍 (上)
- 用html和jsp实现网站的登陆功能
- box2d碰撞设定顶点
- 【每天一个Linux命令】09. Linux中chown的用法
- ASP.NET MVC 入门介绍 (下)
- WP_Query的使用方法
- IBM AppScan 8.6 据说引入了XSS Analyzer比较强
- 在eclipse中用tomca和mysql调试b3log
- 转:Android app项目开发步骤总结
- 如何测试数据库