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

📄 reg_edit.jsp

📁 基于jsp的网络百宝箱
💻 JSP
字号:
<%@ page language="java" contentType="text/html; charset=GBK" pageEncoding="GB18030"%>
<%@ include file="config.ini"%>
<%@ include file="conn.jsp"%>
<%@ include file="readlogin.jsp"%>
<%@ include file="md5.jsp"%>
<%
//接收请求中的参数信息
String action=request.getParameter("action");
if(action==null) {action="";}
//如果请求中的参数为save,则保存修改后的用户信息
if(action.equals("save"))
  {
       //接收用户输入的要修改的用户信息
	   String password=codeToString(request.getParameter("password"));
       String email=codeToString(request.getParameter("email"));
       String qq=codeToString(request.getParameter("qq"));
       sqlstr="update [users] set [email]='"+email+"',[qq]='"+qq+"'";
       if(!password.equals(""))
       {
         password=md5(password);
         sqlstr=sqlstr+",[password]='"+password+"'";
       }
       sqlstr=sqlstr+" where id="+iCan;
       
    try
      {
		 //调用JavaBean对象中的数据库更新方法,执行SQL更新语句,用以更改数据库中的存储信息
         iCanDb.doUpdate(sqlstr);
         out.print("<script>");
         out.print("alert('修改成功!');");
         out.print("location.href='index.jsp';");
         out.print("</script>");
      }
    catch(Exception e)
      {
        out.print("<script>");
        out.print("alert('数据库错误!');");
        out.print("location.href='index.jsp';");
        out.print("</script>");
      }
  }
try
 {
   sqlstr="select * from users where id="+iCan;
   rs=iCanDb.doSelect(sqlstr);
   if(rs.next())
     {
       String password=rs.getString("password");
       String email=rs.getString("email");
       String qq=rs.getString("qq");
%>

<html>
<head>
<%@ include file="head.jsp"%>
</head>

<body>
<script language="javascript">
 function on_submit()
 {//验证数据的合法性
    if (form1.password.value != form1.confirmpwd.value)
			 {
			  alert("两次输入的密码不一致!");
			  form1.password.focus();
			  return false;
			 }
    if (form1.email.value.length!= 0)
		{
			for (i=0; i<form1.email.value.length; i++)
			  if (form1.email.value.charAt(i)=="@")
					break;
			if (i==form1.email.value.length)
			{
			  alert("非法Email地址!");
			  form1.email.focus();
			  return false;
			 }	
		}
 }
</script>
<div align="center">
<table border="0" width="500" id="table2" cellspacing="0" cellpadding="0">
<tr><td>
	<p align="center"><img src="images/logo.gif"></td></tr>
<tr><td>
	 </td></tr>
</table>
<table border="0" width="500" id="table2" cellspacing="0" cellpadding="0">
			<tr>
				<td><table border="0" width="100%" id="table2" cellspacing="0" cellpadding="0"><tr>
				<td height="25" align="left" valign="middle" background="images/tdbg1.gif">
				<table border="0" width="100%" id="table3" cellspacing="0" cellpadding="0">
					<tr>
						<td>
						<p align="center">
						<font size="2" color="#FFFFFF"><b>用户资料修改</b></font></td>
					</tr>
				</table>
				</td></tr></table></td>
			</tr>
			<tr>
				<td>
				<form method="POST" action="reg_edit.jsp?action=save" style="text-align: center" name="form1" onsubmit="return on_submit()">
				<table border="1" width="100%" id="table4" bordercolor="#156FC7" style="border-collapse: collapse" cellpadding="3" cellspacing="0">
					<tr>
						<td width="20%" height="32">
						<p align="center"><font size="2" color="#156FC7"><b>密&nbsp; 
						码</b></font></td>
						<td height="32" width="77%">
						<p align="center">
						<font color="#156FC7">
						<input name="password" size="15" style="border: 1px solid #156FC7" type="password"><span style="font-size: 9pt; font-weight: 700">(不修改请留空)</span></font></td>
					</tr>
					<tr>
						<td width="20%" height="32">
						<p align="center"><font size="2" color="#156FC7"><b>确认密码</b></font></td>
						<td height="32" width="77%">
						<p align="center">
						<font color="#156FC7">
						<input name="confirmpwd" size="15" style="border: 1px solid #156FC7" type="password"><span style="font-size: 9pt; font-weight: 700">(不修改请留空)</span></font></td>
					</tr>
					<tr>
						<td width="20%" height="32">
						<p align="center"><font size="2" color="#156FC7"><b>
						email</b></font></td>
						<td height="32" width="77%">
						<p align="center">
						<font color="#156FC7">
						<input name="email" size="15" style="border: 1px solid #156FC7" value="<%=email%>">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></td>
					</tr>
					<tr>
						<td width="20%" height="32">
						<p align="center"><font size="2" color="#156FC7"><b>QQ号</b></font></td>
						<td height="32" width="77%">
						<p align="center">
						<font color="#156FC7">
						<input name="qq" size="15" style="border: 1px solid #156FC7" value="<%=qq%>">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></td>
					</tr>
					<tr>
						<td colspan="2">
						<p align="center">
						<input type="submit" value="提交" name="B1" style="border: 1px solid #156FC7">&nbsp;&nbsp;&nbsp;
						<input type="button" value="返回" name="B2" style="border: 1px solid #156FC7" onclick="javascript:location.href='index.jsp';"></td>
					</tr>
					</table>
				</td>
			</tr>
			<tr>
				<td> </td>
			</tr>
			<tr>
				<td> </td>
			</tr>
		</table>
</div>
</body>
</html>
<%
   }
   else
   {
         out.print("<script>");
         out.print("alert('id错误!');");
         out.print("location.href='index.jsp';");
         out.print("</script>");
   }
}
catch(Exception e)
{
         out.print("<script>");
         out.print("alert('数据库错误!');");
         out.print("location.href='index.jsp';");
         out.print("</script>");
}
%>

⌨️ 快捷键说明

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