美文网首页
Jsp实现的简单用户管理系统(修改信息界面)

Jsp实现的简单用户管理系统(修改信息界面)

作者: Ro0t | 来源:发表于2018-07-01 14:51 被阅读0次

我的数据库用的是mysql,名字是db_01,账号和密码都是root
1.Change_info.jsp

  <%@ page language="java" contentType="text/html; charset=UTF-8" import="java.sql.*"  
        pageEncoding="UTF-8"%>  

<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=gb2312">
<meta http-equiv="Content-Language" content="zh-cn">
<title>用户注册信息修改</title>
<script language='javascript'>alert('别忘了勾选性别和通信地址!!!')</script>
<link rel=stylesheet href="style.css" type="text/css">
<script language="javascript" src="popcalendar.js"></script>
<script  language="javascript" src="provinceCity.js"></script>
<script language="javascript"   src="validate.js"></script>
</head>


<body bgColor="#2EFEF7" >
<div align=center>


 
<%
String driver = "com.mysql.jdbc.Driver";  
Class.forName(driver);
//2.得到链接
// URL指向要访问的数据库名world        
String url = "jdbc:mysql://localhost:3306/db_01";  
Connection conn=DriverManager.getConnection(url,"root","root");
//3.得到statement
Statement statement = conn.createStatement();  
//4查询数据库


String name2=(String)session.getValue("name");
   String sql="select * from user where usr='"+name2+"'";
   
   ResultSet rs = statement.executeQuery(sql); 
  
  String password0="";
  String confirmpwd0="";
  String sex0="";
  String birthday0="";
  String graduateschool0="";
  String qualification0="";
  String address0="";
  String telephone0="";
  String email0="";
  String question0="";
  String answer0="";
  String hobbies0="";
  if(rs.next())
  {
     password0=rs.getString("passwd");
     confirmpwd0=rs.getString("confirmpwd");
     sex0=rs.getString("sex");
     birthday0=rs.getString("birthday");
     graduateschool0=rs.getString("graduateschool");
     qualification0=rs.getString("qualification");
     address0=rs.getString("address");
     telephone0=rs.getString("telephone");
     email0=rs.getString("email");
     question0=rs.getString("question");
     answer0=rs.getString("answer");
     hobbies0=rs.getString("hobbies");
     rs.close();
    }
  %>
<p><font size="5" face="隶书">修改会员信息</font>
<br><br>
<font size=2 color=red>以下加星号(*)的是必填项</font>
<form name="form1" method="post" action="ok_changeinfo.jsp" onsubmit="javasrcipt:return validate();"> 
 <input type="hidden" name="txtUserName" value='<%=name2%>'>                                     
<table border="1" width="50%"   bordercolor="00a600" bgcolor=lightblue cellspacing="0"> 


  
 <tr>
 <td width="15%" align="center"><font size="2">用&nbsp;户&nbsp;名:</font></td>
<td width="35%" align=left ><input type="text" name="txtUserName" size="20" maxlength="20"  value='<%=name2%>'>

<font size="2" color="red">*(惟一)</font></td></tr>

  <tr>
  <td width="15%" align="center"><font size="2">密&nbsp;码:</font></td>
<td width="35%" align=left><input type="password" name="txtPassword" size="20" maxlength="20"  value='<%=password0 %>'>
<font size="2"
color="#ff0000">*(6-15位)
 </font></td> </tr>
 
 
 <tr>
 <td width="15%" align="center"><font size="2">确&nbsp;认&nbsp;密&nbsp;码:</font></td>
<td width="35%" align=left><input type="password" name="txtConfirmpwd" size="20" maxlength="20"  value='<%=confirmpwd0%>'>
 
 <font size="2" color="#ff0000">*(6-15位)</font>  
   </td>
   </tr>
   
   
   <tr>
   <td  colspan="2" align="center" height="32">
   <font size="2" color="#00000ff">-------以下部分是您的私人材料,承诺为您保密------</font></td>
   </tr>
   
  
   <tr>
   <td width="15%" align="center"><font size="2">性&nbsp;别:</font></td>
   <td width="35%" align=left>
   <input type="radio" name="txtSex" value="男">男
   <input type="radio" name="txtSex" value="女">女
   </td>
   </tr>
   
   
   <tr>
        <td width="15%" align="center"><font size="2">出&nbsp;生&nbsp;日&nbsp;期:<font></td>
        <td width="35%" align="left">
       <input name="txtBirthday" type="text" value='<%=birthday0%>' ><a href="#" onClick="popUpCalendar(this, form1.txtBirthday, 'yyyy-mm-dd'); return false;"><IMG src="pic/calendar/date_selector.gif" border="0" align="absMiddle" alt="日期选择"></a>
         </td>
         </tr>

     <tr>
     <td width="15%" align="center"><font size="2">毕&nbsp;业&nbsp;院&nbsp;校:</font></td>
    <td width="35%"><input type="text" name="txtGraduateschool" size="30" value='<%=graduateschool0 %>'
        maxlength="30" ></td>
        </tr>
     
          <tr>
     <td width="15%" align="center"><font size="2">学&nbsp;历:</font></td>
    <td width="35%">
    <select  name="txtQualification" size="1" >
       <option value=高中以下>高中以下
     <option value=高中>高中
    <option value=大学本科 selected>大学本科
    <option value=大学专科>大学专科
    <option value=研究生>研究生
    <option value=博士/博士后>博士/博士后
    <option value=其它>其它
    </select></td>
        </tr>
     
        
        
      <tr>
      <td width="15%" align="center"><font size="2">通&nbsp;信&nbsp;地&nbsp;址:</font></td>
     <td width="35%"><select name="province" ></select><font size="2">省</font>
     <select name="city"></select><font size="2">市</font>
     </tr>
  
     
     
     
     
     <tr>
     <td width="15%" align="center"><font size="2">联&nbsp;系&nbsp;电&nbsp;话:</font></td>
    <td width="35%"><input type="text" name="txtTelephone" size="20"  value=<%=telephone0 %>
        maxlength="20" ></td>
        </tr>
        
        <tr>
        <td width="15%" align="center"><font size="2">Email:</font></td>
        <td width="35%"><input type="text" name="txtEmail" size="30" value=<%=email0 %>>
        <font size="2" color="red">*</font>
        </td>
        </tr>
        
        <tr>
        <td width="15%" align=center><font size="2">获&nbsp;取&nbsp;密&nbsp;码&nbsp;提&nbsp;示:</font></td>
        <td width="35%"><input type="text" name="txtQuestion" size="30" value='<%=question0 %>'>
        <font size="2" color="red">*</font>
        </td>
        </tr>
        
         <tr>
        <td width="15%" align="center"><font size="2">密&nbsp;码&nbsp;提&nbsp;示&nbsp;答&nbsp;案:</font></td>
        <td width="35%"><input type="text" name="txtAnswer" size="30" value='<%=answer0 %>'>
        <font size="2" color="red">*</font>
        </td>
        </tr>
        
      <tr>  
     <td width="15%" align="center"><font size="2">个&nbsp;人&nbsp;爱&nbsp;好:</font></td>
      <td width="35%"><font size=2> 
        <input name=txtHobbies type=text size=30 value='<%=hobbies0 %>'>
       </font>
       </td>
        </tr>
        
        <tr>
        <td colspan="3" align="center">
        <input type="submit" value="修改" name="submit" class="buttonface">&nbsp;&nbsp;
        <input type="reset" value="取消" name="reset" class="buttonface"onclick="history.back()"></td>
        </tr>   
        </table>
        </form>
        
        
        <br><p></p><br>
       <%@include file="footer.jsp" %>
        </div>
        </body>
        </html>



2.Check_Change_info.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8" import="java.sql.*"  
        pageEncoding="UTF-8"%> 
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="Content-Language" content="zh-cn">
<title>处理会员修改注册信息</title>


 <link rel=stylesheet href="style.css" type="text/css">
</head>
<body bgcolor="#2EFEF7">

<div align=center>
<%@include file="title.jsp"%>
  <br>
<font size="5" face="隶书">用户注册信息修改</font><br>


<%


//4查询数据库

        //获取提交的用户名
        String strUserName=request.getParameter("txtUserName");
        strUserName=new String(strUserName.getBytes("ISO8859-1"),"UTF-8");
        //获取提交的密码
        String strPassword=request.getParameter("txtPassword");
         strPassword=new String(strPassword.getBytes("ISO8859-1"),"UTF-8");
        
        //获取确认密码
        String strConfirmpwd=request.getParameter("txtConfirmpwd");
        strConfirmpwd=new String(strConfirmpwd.getBytes("ISO8859-1"),"UTF-8");
        //获取注册人性别
        String strSex=request.getParameter("txtSex");
        strSex=new String(strSex.getBytes("ISO8859-1"),"UTF-8");
        //获取出生日期
        String strBirthday=request.getParameter("txtBirthday");
        strBirthday=new String(strBirthday.getBytes("ISO8859-1"),"UTF-8");
        //获取毕业院校
        String strGraduateschool=request.getParameter("txtGraduateschool");
        strGraduateschool=new String(strGraduateschool.getBytes("ISO8859-1"),"UTF-8");
        //获取学历
        String strQualification=request.getParameter("txtQualification");
        strQualification=new String(strQualification.getBytes("ISO8859-1"),"UTF-8");
        //获取地址
        String strAddress=request.getParameter("province")+request.getParameter("city");
        strAddress=new String(strAddress.getBytes("ISO8859-1"),"UTF-8");
        //获取联系电话
        String strTelephone=request.getParameter("txtTelephone");
        strTelephone=new String(strTelephone.getBytes("ISO8859-1"),"UTF-8");
        //获取电子信箱地址
        String strEmail=request.getParameter("txtEmail");
        strEmail=new String(strEmail.getBytes("ISO8859-1"),"UTF-8");
         //获取找回密码提示信息
        String strQuestion=request.getParameter("txtQuestion");
        strQuestion=new String(strQuestion.getBytes("ISO8859-1"),"UTF-8");
        //获取找回密码提示信息答案
        String strAnswer=request.getParameter("txtAnswer");
        strAnswer=new String(strAnswer.getBytes("ISO8859-1"),"UTF-8");
        //获取个人爱好信息
        
        String strHobbies=request.getParameter("txtHobbies");
        strHobbies=new String(strHobbies.getBytes("ISO8859-1"),"UTF-8");
        
        String driver = "com.mysql.jdbc.Driver";  
        Class.forName(driver);
        //2.得到链接
        // URL指向要访问的数据库名world        
        String url = "jdbc:mysql://localhost:3306/db_01";  
        Connection conn=DriverManager.getConnection(url,"root","root");
        //3.得到statement
        Statement statement = conn.createStatement();  
        
        String sql="update user set  passwd='"+strPassword+"',confirmpwd='"+strConfirmpwd+"',sex='"+strSex+"',birthday='"+strBirthday+"',graduateschool='"+strGraduateschool+"',qualification='"+strQualification+"',address='"+strAddress+"',telephone='"+strTelephone+"',email='"+strEmail+"',question='"+strQuestion+"',answer='"+strAnswer+"',hobbies='"+strHobbies+"'  where usr='"+strUserName+"'"; 
        statement.executeUpdate(sql);
        
        out.println(strUserName+ "的信息修改完毕");
        
        
        
        %>
        <div onload="load2()">
        
       <script language="javascript">
      

        function load2()
        {
        opener.setTimeout("submit01()",1500)
        self.setTimeout("exit()",1500)
        }
        function exit()
        {
        window.close()
        }
         function submit01()
        {
        Self.location.replace("index.html")
        }
        </script>
        </div>
        
                
        <br><h2><a href="showUser.jsp">点击查看用户</a></h2><br><br><br><br><br>
       <%@include file="footer.jsp" %>
        </div>
        </body>
        </html>
     
        

查看后续代码请看这里👉后续代码

相关文章

网友评论

      本文标题:Jsp实现的简单用户管理系统(修改信息界面)

      本文链接:https://www.haomeiwen.com/subject/ykncuftx.html