login.css
#login{
width: 1000px;
margin: 0 auto;
}
#login p{
text-align: center;
}
.t1{
font-size:28px;
font-family:"微软雅黑";
}
.t2{
font-size:15px;
font-family:"微软雅黑";
color:#999999;
}
.textbox{
width:350px;
height:40px;
border: 1px solid #e2b709;
border-radius:4px;
padding-left:10px;
}
.sumbit{
width:360px;
height:40px;
background-color:#F0184d;
background-color:white;
border:1px solid #666666;
}
.button{
width:360px;
height:40px;
padding-left:10px;
background-color:white;
border:1px solid #666666;
}
.text{
width:360px;
margin:0 auto;
font-size:15 px;
color :#666666;
}
login.html
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<link href="login.css" rel="stylesheet" type="text/css">
</head>
<body >
<div id="login">
<p><img src="C:/Users/user/Desktop/QQ截图20220424101217.png" width="50%" height="50%"></p>
<p class="t1">名片管理系统</p>
<p class="t2">登入页面</p>
<form action="dengru.jsp" method="post">
<p><input type="text" class="textbox" placeholder="请输入账号:" name="zh"></p>
<p><input type="password" class="textbox" placeholder="请输入密码:" name="mima"></p>
<p><input type="submit" value="确认登入" class="sumbit"></p>
</form>
<p class="text" style="text-align:right">忘记密码</p>
<form action="dengru2.jsp" method="post">
<p><input type="submit" value="注册账号" class="button" ></p>
</form>
</div>
</body>
</html>
dengru.jsp
<%@ 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>
<%@ page import="java.sql.*,java.io.*"%>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<link href="login.css" rel="stylesheet" type="text/css">
</head>
<body>
<div id="login">
<%
String a=request.getParameter("zh");
String b=request.getParameter("mima");
String diverName="com.mysql.jdbc.Driver";
String userName="root";
String userPwd="123456";
try{
String dbName="students";
String url1="jdbc:mysql://localhost:3306/"+dbName;
String url2="?user="+userName+"&password="+userPwd;
String url3="&useUnicode=true&characterEncoding=UTF-8";
String url=url1+url2+url3;
Class.forName(diverName);
Connection conn= DriverManager.getConnection(url);
String sql2="select * from login";
PreparedStatement pstmt1=conn.prepareStatement(sql2);
ResultSet rs=pstmt1.executeQuery();
String aa;
String bb;
int flag=0;
while(rs.next())
{
aa=rs.getString("zh");
bb=rs.getString("pwd");
if(aa.equals(a)&&bb.equals(b))
{
%>
<jsp:forward page="index.jsp"></jsp:forward>
<%
flag=1;
break;
}
}
if(flag==0)
{
%>
<p class="t1"><font color="red">用户名或密码错误</font></p>
<p class="t1"><font >如果您还没有注册,可点击下方链接进行注册</font></p>
<p class="t1"><a href="dengru2.jsp">用户注册</a></p>
<%
}
%>
<%
rs.close();
pstmt1.close();
conn.close();
}catch(Exception e){
e.printStackTrace();
}
%>
</div>
</body>
</html>
dengru2.jsp
<%@ 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>
<link href="login.css" rel="stylesheet" type="text/css">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<div id="login">
<p class="t1">名片管理系统</p>
<p class="t2">注册页面</p>
<form action="dengru3.jsp" method="post">
<p><input type="text" class="textbox" placeholder="请输入账号:" name="zh1"></p>
<p><input type="password" class="textbox" placeholder="请输入密码:" name="mima1"></p>
<p><input type="submit" value="确认注册" class="sumbit"></p>
</form>
</div>
</body>
</html>
dengru3.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ page import="java.sql.*,java.io.*"%>
<!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>
<link href="login.css" rel="stylesheet" type="text/css">
</head>
<body>
<div id="login">
<%
String diverName="com.mysql.jdbc.Driver";
String userName="root";
String userPwd="123456";
try{
String dbName="students";
String url1="jdbc:mysql://localhost:3306/"+dbName;
String url2="?user="+userName+"&password="+userPwd;
String url3="&useUnicode=true&characterEncoding=UTF-8";
String url=url1+url2+url3;
Class.forName(diverName);
Connection conn= DriverManager.getConnection(url);
String sql="insert into login(zh,pwd) values(?,?)";
PreparedStatement pstmt=conn.prepareStatement(sql);
request.setCharacterEncoding("UTF-8");
String name=request.getParameter("zh1");
String sex=request.getParameter("mima1");
pstmt.setString(1, name);
pstmt.setString(2, sex);
int n=pstmt.executeUpdate();
if(n>0)
{
%>
<p class="t1"><font color="red">注册成功</font></p>
<p class="t1"><a href="login.html">回到登入页面</a></p>
<%
}
else
{
%>
<p class="t1"><font color="red">注册失败</font></p>
<% }
pstmt.close();
conn.close();
}catch(Exception e){
e.printStackTrace();
}
%>
</div>
</body>
</html>
index.jsp
<%@ 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>网上名片管理系统</title>
</head>
<body >
<iframe align="top" src="index_title.jsp" width="100%" height="30%" scrolling="no" frameborder="0"></iframe>
<iframe align="left" src="index_left.jsp" width="40%" height="330" scrolling="no" frameborder="0"></iframe>
<iframe align="right" src="index_right.jsp" width="60%" height="450" scrolling="no" frameborder="0" name="right"></iframe>
</body>
</html>
index-title.jsp
<%@ 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>网上图片管理系统</title>
</head>
<body>
<h1 align="center">欢迎进入网上图片管理系统</h1>
</body>
</html>
index-left.jsp
<%@ 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>网上名片管理系统</title>
</head>
<body>
<h3>功能介绍:</h3>
<p ><a href="add.jsp" target="right">增加名片</a></p>
<p ><a href="xiugai.jsp" target="right">修改名片</a></p>
<p ><a href="chaxun.jsp" target="right">查询名片</a></p>
<p ><a href="shanchu.jsp" target="right">删除名片</a></p>
<p ><a href="hs-index.jsp" target="right">回收站管理</a></p>
</body>
</html>
index-right.jsp
<%@ 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>网上图片管理系统</title>
</head>
<body>
</body>
</html>
add.jsp
<%@ 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>增加名片</title>
</head>
<body>
<form action="add2.jsp" method="post">
<font size="4" color="red">信息添加</font><br/>
编号 <input type="text" name="id"><br/>
姓名 <input type="text" name="name"><br/>
性别 <input type="text" name="sex"><br/>
<input type="submit" value="提 交">
<input type="reset" value="取 消">
</form>
</body>
</html>
add2.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ page import="java.sql.*,java.io.*"%>
<!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 diverName="com.mysql.jdbc.Driver";
String userName="root";
String userPwd="123456";
try{
String dbName="students";
String url1="jdbc:mysql://localhost:3306/"+dbName;
String url2="?user="+userName+"&password="+userPwd;
String url3="&useUnicode=true&characterEncoding=UTF-8";
String url=url1+url2+url3;
Class.forName(diverName);
Connection conn= DriverManager.getConnection(url);
String sql="insert into mingpian(id,name,sex) values(?,?,?)";
PreparedStatement pstmt=conn.prepareStatement(sql);
request.setCharacterEncoding("UTF-8");
int id=Integer.parseInt(request.getParameter("id"));
String name=request.getParameter("name");
String sex=request.getParameter("sex");
pstmt.setInt(1, id);
pstmt.setString(2, name);
pstmt.setString(3, sex);
int n=pstmt.executeUpdate();
if(n>0)
{
out.print("添加记录成功,共添加了"+n+"记录!");
}
else
{
out.print("添加记录不成功!");
}
%>
<br/>
<a href="add.jsp">点击此处再次添加</a>
<%
pstmt.close();
conn.close();
}catch(Exception e){
e.printStackTrace();
}
%>
</body>
</html>
xiugai.jsp
<%@ 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>
<form action="xiugai2.jsp" method="post">
<font color="red">更新编号</font><br/>
旧编号:<input type="text" name="idodd"><br/>
新姓名:<input type="text" name="name"><br/>
新编号:<input type="text" name="id"> <br/>
<input type="submit" value="提 交">
<input type="reset" value="取 消">
</form>
</body>
</html>
xiugai2.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ page import="java.sql.*,java.io.*"%>
<!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 diverName="com.mysql.jdbc.Driver";
String userName="root";
String userPwd="123456";
try{
String dbName="students";
String url1="jdbc:mysql://localhost:3306/"+dbName;
String url2="?user="+userName+"&password="+userPwd;
String url3="&useUnicode=true&characterEncoding=UTF-8";
String url=url1+url2+url3;
Class.forName(diverName);
Connection conn= DriverManager.getConnection(url);
String sql="update mingpian set name=?,id=? where id=?";
PreparedStatement pstmt=conn.prepareStatement(sql);
request.setCharacterEncoding("UTF-8");
int oddc=Integer.parseInt(request.getParameter("idodd"));
int c=Integer.parseInt(request.getParameter("id"));
String nn=request.getParameter("name");
pstmt.setString(1, nn);
pstmt.setInt(2, c);
pstmt.setInt(3, oddc);
int n=pstmt.executeUpdate();
if(n>0)
{
out.print("更新记录成功,共更新了"+n+"记录!");
}
else
{
out.print("更新记录不成功!");
}
%>
<%
pstmt.close();
conn.close();
}catch(Exception e){
e.printStackTrace();
}
%>
</body>
</html>
chaxun.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ page import="java.sql.*,java.io.*"%>
<!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 diverName="com.mysql.jdbc.Driver";
String userName="root";
String userPwd="123456";
try{
String dbName="students";
String url1="jdbc:mysql://localhost:3306/"+dbName;
String url2="?user="+userName+"&password="+userPwd;
String url3="&useUnicode=true&characterEncoding=UTF-8";
String url=url1+url2+url3;
Class.forName(diverName);
Connection conn= DriverManager.getConnection(url);
String sql2="select * from mingpian";
PreparedStatement pstmt1=conn.prepareStatement(sql2);
ResultSet rs=pstmt1.executeQuery();
rs.last();
%>
你要查询的有
<font size="5" color="red"><%=rs.getRow()%></font>人
<table border="2" width="650">
<tr align="center">
<td>记录条数</td>
<td>编号</td>
<td>姓名</td>
<td>性别</td>
<tr>
<%rs.beforeFirst();
while(rs.next()){
%>
<tr align="center">
<td><%=rs.getRow()%></td>
<td><%=rs.getString("id")%></td>
<td><%=rs.getString("name")%></td>
<td><%=rs.getString("sex")%></td>
</tr>
<%} %>
</table>
<%
rs.close();
pstmt1.close();
conn.close();
}catch(Exception e){
e.printStackTrace();
}
%>
</body>
</html>
shanchu.jsp
<%@ 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>
<form action="shanchu2.jsp" method="post">
请输入你要删除的编号:<br/>
<input type="text" name="id"><br/>
<input type="submit" value="提 交"> <input type="reset" value="取 消">
</form>
</body>
</html>
shanchu2.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ page import="java.sql.*,java.io.*"%>
<!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 diverName="com.mysql.jdbc.Driver";
String userName="root";
String userPwd="123456";
try{
String dbName="students";
String url1="jdbc:mysql://localhost:3306/"+dbName;
String url2="?user="+userName+"&password="+userPwd;
String url3="&useUnicode=true&characterEncoding=UTF-8";
String url=url1+url2+url3;
Class.forName(diverName);
Connection conn= DriverManager.getConnection(url);
request.setCharacterEncoding("UTF-8");
Connection conn1= DriverManager.getConnection(url);
String sql1="insert into hs(id,name,sex) values(?,?,?)";
PreparedStatement pstmt2=conn1.prepareStatement(sql1);
Connection conn2= DriverManager.getConnection(url);
String sql="delete from mingpian where id=?";
PreparedStatement pstmt=conn2.prepareStatement(sql);
String sql2="select * from mingpian where id=?";
PreparedStatement pstmt1=conn.prepareStatement(sql2);
int id=Integer.parseInt(request.getParameter("id"));
pstmt1.setInt(1, id);
ResultSet rs=pstmt1.executeQuery();
rs.beforeFirst();
if(rs.next())
{
pstmt2.setInt(1,rs.getInt("id"));
pstmt2.setString(2,rs.getString("name"));
pstmt2.setString(3,rs.getString("sex"));
pstmt.setInt(1,rs.getInt("id"));
int n1=pstmt.executeUpdate();
int n=pstmt2.executeUpdate();
%>
<jsp:forward page="shanchu3.jsp"></jsp:forward>
<%
}
else
{
out.print("未找到该条信息!");
}
%>
<%
rs.close();
pstmt1.close();pstmt2.close();pstmt.close();
conn.close();
}catch(Exception e){
e.printStackTrace();
}
%>
</body>
</html>
shanchu3.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ page import="java.sql.*,java.io.*"%>
<!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>
<p>已删除该条信息并将他放到回收站中!</p>
</body>
</html>
hs-index.jsp
<%@ 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>
<h3>回收站功能介绍:</h3>
<p><a href="huishou2.jsp" target="right">一键删除</a></p>
<p><a href="huishou.jsp" target="right">一键查询</a></p>
<p><a href="huishou3.jsp" target="right">一键还原</a></p>
</body>
</html>
household.jsp
<%@ 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>
<h3>回收站功能介绍:</h3>
<p><a href="huishou2.jsp" target="right">一键删除</a></p>
<p><a href="huishou.jsp" target="right">一键查询</a></p>
<p><a href="huishou3.jsp" target="right">一键还原</a></p>
</body>
</html>
household2.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ page import="java.sql.*,java.io.*"%>
<!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 diverName="com.mysql.jdbc.Driver";
String userName="root";
String userPwd="123456";
try{
String dbName="students";
String url1="jdbc:mysql://localhost:3306/"+dbName;
String url2="?user="+userName+"&password="+userPwd;
String url3="&useUnicode=true&characterEncoding=UTF-8";
String url=url1+url2+url3;
Class.forName(diverName);
Connection conn= DriverManager.getConnection(url);
String sql2="delete from hs";
PreparedStatement pstmt1=conn.prepareStatement(sql2);
int n1=pstmt1.executeUpdate();
if(n1>0)
{
out.println("删除记录成功,共删除了"+n1+"记录!");
}
else
{
out.println("删除记录不成功!");
}
%>
<%
pstmt1.close();
conn.close();
}catch(Exception e){
e.printStackTrace();
}
%>
</body>
</html>
household3.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ page import="java.sql.*,java.io.*"%>
<!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 diverName="com.mysql.jdbc.Driver";
String userName="root";
String userPwd="123456";
try{
String dbName="students";
String url1="jdbc:mysql://localhost:3306/"+dbName;
String url2="?user="+userName+"&password="+userPwd;
String url3="&useUnicode=true&characterEncoding=UTF-8";
String url=url1+url2+url3;
Class.forName(diverName);
Connection conn= DriverManager.getConnection(url);
Connection conn1= DriverManager.getConnection(url);
String sql1="select * from hs";
String sql2="insert into mingpian(id,name,sex) values(?,?,?)";
PreparedStatement pstmt1=conn.prepareStatement(sql1);
PreparedStatement pstmt2=conn1.prepareStatement(sql2);
ResultSet rs=pstmt1.executeQuery();
%>
<%
rs.beforeFirst();
while(rs.next()){
pstmt2.setString(1,rs.getString("id"));
pstmt2.setString(2,rs.getString("name"));
pstmt2.setString(3,rs.getString("sex"));
int n2=pstmt2.executeUpdate();
if(n2>0)
{
out.print("还原成功!");%><br/><%
}
else
{
out.print("还原不成功!");%><br/><%
}
%>
<%} %>
<%
rs.close();
pstmt1.close();
pstmt2.close();
conn.close();conn1.close();
}catch(Exception e){
e.printStackTrace();
}
%>
</body>
</html>