模拟操作银行登入页面。。。未连接数据库

Posted 琢磨先生

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了模拟操作银行登入页面。。。未连接数据库相关的知识,希望对你有一定的参考价值。

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>

<style>
.a
{
	width:390px;
	height:290px;
	background-color:#CCC;
	margin-left:400px;	
	margin-top:10px;
	
	}
.b{ width :390px;
	height:55px;
	background-color:#03C;
	margin-left:0px;	
	margin-top:0px;
	position:relative;
	line-height:55px;text-align:center
	}
.c{ line-height:40px;text-align:center
	
	}
</style>
</head>
<body>

<div class="a">
	<div class="b"><font color="#FFFFFF" >银行登入系统</font>
    	<form action="A.jsp"method="post">
       	用户名:
       	 <input type="text" name="name" placeholder="请输入用名户名"style=" width:200px; height:40px"/><br>
		密码:&nbsp&nbsp&nbsp&nbsp
		<input <input type="password"name="password" placeholder="请输入密码" style=" width:200px; height:40px"/><br><br>
		<input type="submit" value="提交" style=" width:100px; height:40px"/>
        </form>
	</div>

</div>

</body>
</html>

  

<%@page import="java.sql.PreparedStatement"%>
<%@page import="java.sql.ResultSet"%>
<%@page import="java.sql.Statement"%>
<%@page import="java.sql.DriverManager"%>
<%@page import="java.sql.Connection"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<%

//访问数据库
try
{
	Class.forName("oracle.jdbc.driver.OracleDriver");

	Connection conn=DriverManager.getConnection("jdbc:oracle:thin:@127.0.0.1:1521:orcl", 
		"test0816", "123456");
	String sql="select * from ATM where name=? and password=?";
	PreparedStatement ps= conn.prepareStatement(sql);
	ps.setString(1, "name");
	ps.setString(1, "password");
	ResultSet rs = ps.executeQuery();
	if(rs.next())
	{
			out.write("登入成功");
	}
	else
	{
		out.write("登入失败");
	}

}
catch(Exception e)
{
	e.printStackTrace();

}
%>
<br>
<% 
String name =request.getParameter("name"); 
//字符集转码
name=new String (name.getBytes("ISO-8859-1"),"UTF-8");
String password =request.getParameter("password"); 

out.write("用户名:"+name+"<br>");
out.write("密码:"+password);

if(name.equals("张三"))
{
    if(password.equals("123456"))
    {
%>
        <!-- 账号密码正确跳转登陆页面-->
        <jsp:forward page="success.jsp"></jsp:forward>
<% 
    }
    else
    {
%>
        <!-- 账号正确密码错误跳转密码错误提示页面 -->
        <jsp:forward page="failPassword.jsp"></jsp:forward>
<% 
    }
}
else
{
%>
    <!-- 账号错误跳转账号错误提示页面 -->
    <jsp:forward page="failName.jsp"></jsp:forward>
<% 
}

%>
</body>
</html>

  

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
跳转登入成功的页面......<br>
登入成功!
</body>
</html>

  

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
用户名输入错误或不存在的页面<br>
用户名不存在!
</body>
</html>

  

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
密码输入错误跳转页面。。。。<br>
密码错误!
</body>
</html>

 

<%@page import="java.sql.ResultSet"%>
<%@page import="java.sql.PreparedStatement"%>
<%@page import="java.sql.DriverManager"%>
<%@page import="java.sql.Connection"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<%
//接受数据
String cairnumber =request.getParameter("cairnumber");
String password =request.getParameter("password");
if(cairnumber==null || password == null)
{
out.write("请正确登录系统");

}
else
{
	Class.forName("oracle.jdbc.driver.OracleDriver");
	Connection conn =DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:orcl",
			"test0816","123456");
	
	PreparedStatement ps =conn.prepareStatement("select*from ATM where cairnumber=? and password=?");
	ps.setString(1, cairnumber);
	ps.setString(2, password);
	ResultSet rs =ps.executeQuery();
	if(rs.next())
	{
		
		out.write("用户名和密码正确,登入成功");
	}
	else
	{
		out.write("用户名或密码错误");
	}
	rs.close();
	ps.close();
	conn.close();
//数据验证

//连接数据库

	
}



%>


</body>
</html>

  在web中连接数据库,odjbc6.jar的包要放在WEB-INF目录下的lib文件夹下面

 

 

以上是关于模拟操作银行登入页面。。。未连接数据库的主要内容,如果未能解决你的问题,请参考以下文章

错误:E/RecyclerView:未连接适配器;跳过片段上的布局

连接数据库:登入与处理

一个银行转账示例带你了解CSRF原理,跨站请求伪造(CSRF)示例原理及其防御措施

在带有操作栏的活动中使用时,片段未完全显示

tp5 _initialize控制器初始化 及 禁止未登录进入和重复登入

JSF2 commandButton 操作未在更新的片段中调用