人口普查系统:
修改功能:
<%@ page language="java" contentType="text /html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8d">
<title>Insert title here</title>
</head>
<body>
<form action="Jupdate1.jsp" method="post" onsubmit="return chech(this)">
<td align="center" colspan="2">
<h2>信息修改系统</h2>
<hr>
</td>
<tr>
<td align="right">修改户主的姓名</td>
<td><input type="text" name="name"/></td>
</tr>
<tr>
<td align="center" colspan="2">
<input type="submit" value="修改">
</td>
</tr>
</form>
</body>
</html>
<%@ page language="java" contentType="text/ html; charset=UTF-8"
pageEncoding="UTF-8" import = "java.sql.*"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<%request.setCharacterEncoding("UTF-8"); %>
<%
String name=request.getParameter("name");
session.setAttribute("name",name);
%>
<pre>
<%
String name1=request.getParameter("name");
out.print(name);
Class.forName("com.mysql.cj.jdbc.Driver");
String url = "jdbc:mysql://localhost:3306/test?serverTimezone=GMT%2B8";
String username = "root";
String password="123456";
Connection a = DriverManager.getConnection(url,username,password);
if(a != null){
out.println("数据库连接成功!");
}
Statement stmt=a.createStatement();
String sql="select* from renkou";
ResultSet rs=stmt.executeQuery(sql);
int TEMP=0;
while(rs.next())
{
String namep=rs.getString("户主姓名");
if(name1.equals(namep)==true)
{
TEMP=1;
out.print(rs.getString("户别"));
out.print(" ");
out.print(rs.getString("住房类型"));
out.print(" ");
out.print(rs.getString("本户现住房面积"));
out.print(" ");
out.print(rs.getString("本户现住房间数"));
out.print(" ");
out.print(rs.getString("户主姓名"));
out.print(" ");
out.print(rs.getString("性别"));
out.print(" ");
out.print(rs.getString("身份证号码"));
out.print(" ");
out.print(rs.getString("民族"));
out.print(" ");
out.println(rs.getString("受教育程度"));
}
}
if(TEMP==0)
{
out.println("户主不存在");
}
%>
<form action="Jupdate2.jsp" method="post" onsubmit="return chech(this)">
<table align="center" width="450">
<tr>
<td align="center" >
<h2>添加个人信息信息</h2>
<hr>
</td>
</tr>
<tr>
<td align="right">户别:</td>
<td>
<input type="radio" name="hubie" value="家庭户" checked="checked">家庭户
<input type="radio" name="hubie" value="集体户">集体户
</td>
</tr>
<tr>
<td align="right">住房类型:</td>
<td>
<input type="radio" name="zhufang" value="家庭住宅" checked="checked">家庭住宅
<input type="radio" name="zhufang" value="集体住所">集体住所
<input type="radio" name="zhufang" value="工作地住所">工作地住所
<input type="radio" name="zhufang" value="其他住宅">其他住宅
<input type="radio" name="zhufang" value="无住宅">无住宅
</td>
</tr>
<tr>
<td align="right">本户现住房面积:</td>
<td><input type="text" name="nows"/></td>
</tr>
<tr>
<td align="right">本户现住房间数:</td>
<td><input type="text" name="nowsnum"/></td>
</tr>
<tr>
<td align="right">户主姓名:</td>
<td><input type="text" name="name"/></td>
</tr>
<tr>
<td align="right">身份证号:</td>
<td><input type="text" name="num" maxlength="13"/></td>
</tr>
<tr>
<td align="right">性别:</td>
<td>
<input type="radio" name="sex" value="男" checked="checked">男
<input type="radio" name="sex" value="女">女
</td>
</tr>
<tr>
<td align="right">民族:</td>
<td><input type="text" name="min"/></td>
</tr>
<tr>
文化程度
<select name="edu" size="3" align="right">
<option>研究生</option>
<option>大学本科</option>
<option>大学专科</option>
<option>高中</option>
<option>初中</option>
<option>小学</option>
<option>未上过学</option>
</select>
</tr>
<tr>
<td align="center" colspan="2">
<input type="submit" value="提交">
</td>
</tr>
</table>
</form>
</pre>
</body>
</html>