⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 changepwd.jsp

📁 JSP+ORACLE网站开发实例(下).rar
💻 JSP
字号:
<%request.setCharacterEncoding("GB2312");
String pname= (String) session.getValue("puid"); 
String cname= (String) session.getValue("cuid"); 
String uname= (String) session.getValue("cuid"); 
if(pname==null){
uname=(String) session.getValue("cuid");
}else{
uname=(String) session.getValue("puid");
}
 String	   stypevalue;
String stype=request.getParameter("stype"); %>

<%@ include file="conn.jsp"%>
<%! 
String replacenull(String a){ 
	if(a==null){
return ""; 
	}else{
return a; 
	}
} 
String selected(String a,String b){ 
	if(a==null){
    return ""; 
	}
	if(a.equals(b)){
return "selected"; 
	}else{
return ""; 
	}
} 
%> 

<html>
<head>
<meta http-equiv="Content-Language" content="zh-cn">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link rel="stylesheet" href="inc/register.css" type="text/css">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>天天人才—&gt;修改密码</title>
</head>
<SCRIPT language=JavaScript>
<!--
function checkform()
{
 if (document.changepwd.pwd.value=="") {
		alert("请输入原密码!");
		changepwd.pwd.focus();		
		    return (false);
  }
 if (document.changepwd.newpwd.value=="") {
		alert("请输入新密码!");
		changepwd.pwd.focus();		
		    return (false);
  }
  if (document.changepwd.newpwd.value.length<3) {
    alert("密码不能少于三位!");
    return false;   
  }
  if (document.changepwd.newpwd.value != document.changepwd.newpwd2.value) {
    alert("两次密码输入不一致!");
    document.changepwd.newpwd.value="";
    document.changepwd.newpwd2.value="";
	return false;
  }
  return true;
}
//-->
</SCRIPT>
<form name=changepwd onsubmit="return checkform();" action="changepwd.jsp?stype=<%=stype%>" method=post>
<div align="center">
  <center>
  <table border="1" cellpadding="0" cellspacing="0" width="256" height="180" bordercolor="#000000" bordercolorlight="#000000" bordercolordark="#FFFFFF" bgcolor="#EBEBEB">
    <tr>
      <td width="254" height="1" valign="top" background="images/t-bg1.gif">
        <p align="center">=== 修改密码 ===</td>  
    </tr>
    <tr>
        <td width="254" height="187" valign="top" bgcolor="#fffff4"> 
          <p align="center"><br>
        用户名:<font color="#0000B5"><%=uname%>
		</font>&nbsp;[
		
		<% stypevalue="company";
			if(stypevalue.equals(stype)){
		out.print("单位用户");
			}else{
				out.print("个人用户");
			}%>]</p>
        <p align="center">&nbsp;原密码:<input type="password" name="pwd" size="20" maxLength=20></p>
        <p align="center">&nbsp;新密码:<input type="password" name="newpwd" size="20" maxLength=20></p>
  </center>
        <p align="left">&nbsp;&nbsp; 重复新密码:<input type="password" name="newpwd2" size="20" maxLength=20></p>
  <center>
          <p align="center"><input type="submit" value="修 改" name="B1"><br>
        <br>
      </td>
    </tr>
  </table>
  </center>
</div>
</form>
<p align="center">【<a href="javascript:window.close()">关闭窗口</a>】</p>
<% String pwd=request.getParameter("pwd");
if(pwd!=null){
 String   newpwd=request.getParameter("newpwd");
 stypevalue="person";
   if(stypevalue.equals(stype)){
String sql="select * from scott.person where uname='"+uname+"' and pwd='"+pwd+"'"; 
ResultSet rs=stmt.executeQuery(sql); 
if(!rs.next()){  
   out.print("<SCRIPT language=JavaScript>alert('原密码错误,请重新输入!');");
   out.print("javascript:history.go(-1)</SCRIPT>");
}else{
stmt.executeUpdate("update scott.person set pwd='"+newpwd+"' where uname='"+uname+"' and pwd='"+pwd+"'");
  out.print("<SCRIPT language=JavaScript>alert('密码修改成功');");
   out.print("javascript:window.close();</SCRIPT>");
}
   }

   stypevalue="company";
     if(stypevalue.equals(stype)){
String sql="select * from scott.company where uname='"+uname+"' and pwd='"+pwd+"'"; 
ResultSet rs=stmt.executeQuery(sql); 
if(!rs.next()){  
   out.print("<SCRIPT language=JavaScript>alert('原密码错误,请重新输入!');");
   out.print("javascript:history.go(-1)</SCRIPT>");
}else{
stmt.executeUpdate("update scott.company set pwd='"+newpwd+"' where uname='"+uname+"' and pwd='"+pwd+"'");
  out.print("<SCRIPT language=JavaScript>alert('密码修改成功');");
   out.print("javascript:window.close();</SCRIPT>");
}
   }

} %>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -