JSP User Login Code
<%@ page contenttype= "text/html; charset=gb2312 "language=" java "import=" java.sql.* "errorpage=" "%>"
<% @include file= "db.jsp"%>
<jsp:usebean id= "loginMD5" scope= "page" class= "ITstudy_cn.tool.MD5"/>
<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<html xmlns= "http://www.w3.org/1999/xhtml" >
<%
String path = Request.getcontextpath ();
String basepath = request.getscheme () + "://" +request.getservername () + ":" +request.getserverport () +path+ "/";
%>
<head>
<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 "/>
<title> User Login-</title>
<link href= "Css/style.css" rel= "stylesheet" type= "Text/css"/>
<script language= "JavaScript" >
function Check () {
if (document.myform.username.value== "") {
userror.innerhtml = "User name cannot be empty";
Document.myform.username.focus ();
return False
}
if (document.myform.password.value== "") {
pserror.innerhtml = "Password cannot be null";
Document.myform.password.focus ();
return False
}
}
</script>
<style type=text/css>
. Posterror{color: #FF0000}
</style></head>
<%
if (Request.getparameter ("Dropsubmit")!=null) {
Cookie Deletenewcookie=new Cookie ("username", null);
Deletenewcookie.setmaxage (0);
Response.addcookie (Deletenewcookie);
Out.print ("<script type=" Text/javascript "> Alert" ("Successful Exit"); window.location.href= ' login.jsp ' </script> ' );
return;
}
if (Request.getparameter ("Midisubmit")!=null) {
String Username=new string (Request.getparameter ("username"). GetBytes ("iso-8859-1"));
String Password=new string (request.getparameter ("password"). GetBytes ("iso-8859-1"));
PASSWORD=LOGINMD5.GETMD5OFSTR (password);
String Company=new string (Request.getparameter ("Company"). GetBytes ("iso-8859-1"));
String Conname=new string (Request.getparameter ("Conname"). GetBytes ("iso-8859-1"));
String Email=new string (request.getparameter ("email"). GetBytes ("iso-8859-1"));
String Address=new string (Request.getparameter ("Address"). GetBytes ("iso-8859-1"));
String Content=new string (Request.getparameter ("content"). GetBytes ("iso-8859-1"));
String Tel=new string (Request.getparameter ("tel"). GetBytes ("iso-8859-1"));
String Orderr=new string (Request.getparameter ("Order"). GetBytes ("iso-8859-1"));
Statement stmt_add=conn.createstatement ();
Stmt_add.executeupdate ("Update member Set password= '" +password+ "', content= '" +content+ "', company= '" +company+ "', tel = ' "+tel+" ', Conname= ' "+conname+" ', email= ' "+email+" ', address= ' "+address+" ', qunx= ' "+orderr+" ' where username= ' "+ Username+ "'");
Stmt_add.close ();
Out.print ("<script type=" Text/javascript "> Alert" Data has been successfully modified! "); window.location.href= ' login.jsp '; </script> ");
return;
}
if (Request.getparameter ("Editname")!=null) {
String Editname=new string (Request.getparameter ("Editname"). GetBytes ("iso-8859-1"));
Statement stmt_u2=conn.createstatement (resultset.type_scroll_sensitive,resultset.concur_updatable);
String SQLU2 = "SELECT * from member where username= '" + editname + "'";
ResultSet Rsu2 = Stmt_u2.executequery (SQLU2);
if (Rsu2.next ()) {
%>
<body>
<script language= "JavaScript" >
function Check2 () {
if (document.myform.password.value== "") {
pserror.innerhtml = "Password cannot be null";
Document.myform.password.focus ();
return False
}
if (Document.myform.password.value!=document.myform.password2.value) {
ps2error.innerhtml = "Two times password inconsistency";
Document.myform.password2.focus ();
return False
}
if (document.myform.company.value== "") {
comerror.innerhtml = "Please fill in the correct unit name";
Document.myform.company.focus ();
return False
}
if (document.myform.conname.value== "") {
connameerror.innerhtml = "Please fill in the contact person's name!" ";
Document.myform.conname.focus ();
return False
}
if (document.myform.tel.value== "") {
telerror.innerhtml = "In order to better provide after-sales service, please fill in the correct mobile phone number." ";
Document.myform.tel.focus ();
return False
}
if (document.myform.email.value== "") {
emailerror.innerhtml = "Please fill in the correct email address";
Document.myform.email.focus ();
return False
}
if (document.myform.address.value== "") {
adderror.innerhtml = "Please fill in the address";
Document.myform.address.focus ();
return False
}
}
</script>
<% @include file= "head.jsp"%>
<table width= "1003" border= "0" align= "center" cellpadding= "0" cellspacing= "0" >
<tr>
<TD width= "rowspan=" 3 "style=" Background:url (images/leftbg.jpg) repeat-y right ">&nbsp;</td>
<TD style= "Background-repeat:repeat-x" valign= "Top" align= "Middle"
background= "Images/l_m_bg.jpg" "height=" 370 "><table style=" margin-top:10px; margin-bottom:30px "cellspacing=" 0 "
cellpadding= "0" width= "border=" 0 ">
<tbody>
<tr>
<td><img height= "alt=" "src=" images/u_zc_top.jpg "
Width= "706"/></td>
</tr>
<tr>
<TD align= "Middle" background= "images/n_zc_md.jpg" height= "" ><span
class= "f12red" style= "FONT-SIZE:14PX; Font-weight:bold; COLOR: #cccc00 "> Modify personal Data </span>
<form id= "MyForm" name= "MyForm" onsubmit= "return Check2 ()"
action= "" method= "POST" >
<table class= "K1" style= "margin-top:10px; margin-bottom:15px "
cellspacing= "0" cellpadding= "8" width= "570" align= "center" border= "0" >
<tbody>
<tr>
<TD class= "F14black" align= "right" width= "" "Bgcolor=" "#f0f8ff"
height= "><table" cellspacing= "0" cellpadding= "0" width= "100%" border= "0" >
<tbody>
<tr>
<TD align= "Right" > Username:</td>
</tr>
</tbody>
</table></td>
<TD align= "left" width= "180" height= "a" ><%=rsu2.getstring ("username")%></td>
<TD class= "F12blue" align= "left" width= "248" bgcolor= "#fafafa" ></td>
</tr>
<tr>
<TD class= "k_hui_t" align= "right" bgcolor= "#f0f8ff" height= "" ><table cellspacing= "0" cellpadding= "0" width = "100%" border= "0" >
<tbody>
<tr>
<TD class= "F14black" align= "right" > Password:</td>
<input type= "hidden" name= "username" value= "<%=rsu2.getstring" ("username")%> "/>"
<input type= "hidden" name= "order" value= "<%=rsu2.getstring (" Qunx ")%>"/> "
</tr>
</tbody>
</table></td>
<TD class= "k_hui_t" align= "left" ><input "class=" K1 "type="
Name= "Password"/></td>
<TD class= "F12blue" align= "left" bgcolor= "#fafafa" ><span class= "Posterror" id= "Pserror" > Two changes required to confirm the previous password! </span></td>
</tr>
<tr>
<TD class= "k_hui_t" align= "right" bgcolor= "#f0f8ff" height= "" ><table cellspacing= "0" cellpadding= "0" width = "100%" border= "0" >
<tbody>
<tr>
<TD class= "F14black"
Align= "right" > Confirm password:</td>
</tr>
</tbody>
</table></td>
<TD class= "k_hui_t" align= "left" ><input "class=" K1 "type="
Name= "Password2"/></td>
<TD class= "F12blue" align= "left" bgcolor= "#fafafa" ><span class= "Posterror" id= "Ps2error" > </span> </td>
</tr>
<tr>
<TD class= "k_hui_t" align= "right" bgcolor= "#f0f8ff" height= "" ><table cellspacing= "0" cellpadding= "0" width = "100%" border= "0" >
<tbody>
<tr>
<TD class= "F14black"
Align= "right" > Unit name:</td>
</tr>
</tbody>
</table></td>
<TD class= "k_hui_t" align= "left" ><input "class="
Name= "Company" value= "<%=rsu2.getstring (" Company ")%>"/></td>
<TD class= "F12blue" align= "left" bgcolor= "#fafafa" ><span class= "Posterror" id= "Comerror" > </span> </td>
</tr>
<tr>
<TD class= "k_hui_t" align= "right" bgcolor= "#f0f8ff" height= "" ><table cellspacing= "0" cellpadding= "0" width = "100%" border= "0" >
<tbody>
<tr>
<TD class= "F14black" align= "right" > Contact person:</td>
</tr>
</tbody>
</table></td>
<TD class= "k_hui_t" align= "left" ><input class= "K1" name= "Conname" value= "<%=rsu2.getstring (" conname ")% > "/> </td>
<TD class= "F12blue" align= "left" bgcolor= "#fafafa" ><span class= "Posterror" id= "Connameerror" > </span ></td>
</tr>
<tr>
<TD class= "k_hui_t" align= "right" bgcolor= "#f0f8ff" height= "" ><table cellspacing= "0" cellpadding= "0" width = "100%" border= "0" >
<tbody>
<tr>
<TD class= "F14black" align= "right" > Tel:</td>
</tr>
</tbody>
</table></td>
<TD class= "k_hui_t" align= "left" ><label>
<input class= "K1" name= "tel" value= "<%=rsu2.getstring" ("tel")%> "/>"
</label></td>
<TD class= "F12blue" align= "left"
Bgcolor= "#fafafa" ><span class= "Posterror" id= "Telerror" > </span></td>
</tr>
<tr>
<TD class= "k_hui_t" align= "right" bgcolor= "#f0f8ff" height= "" ><table cellspacing= "0" cellpadding= "0" width = "100%" border= "0" >
<tbody>
<tr>
<TD class= "F14black"
Align= "Right" >E_mail:</td>
</tr>
</tbody>
</table></td>
<TD class= "k_hui_t" align= "left" ><label>
<input class= "K1" name= "email" value= "<%=rsu2.getstring" ("email")%> "/>"
</label></td>
<TD class= "F12blue" align= "left" bgcolor= "#fafafa" ><span class= "Posterror" id= "Emailerror" > </span ></td>
</tr>
<tr>
<TD class= "k_hui_t" align= "right" bgcolor= "#f0f8ff" height= "" ><table cellspacing= "0" cellpadding= "0" width = "100%" border= "0" >
<tbody>
<tr>
<TD class= "F14black" align= "right" > Contact address:</td>
</tr>
</tbody>
</table></td>
<TD class= "k_hui_t" align= "left" ><input class= "K1" name= "Address" value= "<%=rsu2.getstring (" address ")% > "/> </td>
<TD class= "F12blue" align= "left" bgcolor= "#fafafa" ><span class= "Posterror" id= "Adderror" > </span> </td>
</tr>
<tr>
<TD class= "k_hui_t" align= "right" bgcolor= "#f0f8ff" height= "" ><table cellspacing= "0" cellpadding= "0" width = "100%" border= "0" >
<tbody>
<tr>
<TD class= "F14black" align= "right" > Remarks <span
Class= "f12red": (May not fill) </span></td>
</tr>
</tbody>
</table></td>
<TD class= "k_hui_t" align= "left" colspan= "2" ><textarea style= "width:350px; height:60px "name=" content ><%=rsu2.getstring ("content")%></textarea></td>
</tr>
<tr>
<td></td>
<td><input type= "Submit" value= "submitted" name= "Midisubmit"/></td>
</tr>
</tbody>
</table>
</form></td>
</tr>
<tr>
<td><img height= "Notoginseng" alt= "src=" Images/n_zc_down.jpg "
Width= "706"/></td>
</tr>
</tbody>
</table></td>
<TD width= "rowspan=" 3 "style=" Background:url (images/rightbg.jpg) repeat-y left ">&nbsp;</td>
</tr>
</tbody>
</table>
<% @include file= "foot.jsp"%>
</body>
</html>
<%
}
Rsu2.close ();
Stmt_u2.close ();
return;
}
if (Request.getparameter ("Logincheck")!=null) {
Cookie Deletenewcookie=new Cookie ("username", null);
Deletenewcookie.setmaxage (0);
Response.addcookie (Deletenewcookie);
String Username=new string (Request.getparameter ("username"). GetBytes ("iso-8859-1"));
String Password=new string (request.getparameter ("password"). GetBytes ("iso-8859-1"));
PASSWORD=LOGINMD5.GETMD5OFSTR (password);
Statement stmt_check=conn.createstatement (resultset.type_scroll_sensitive,resultset.concur_updatable);
String sql = "SELECT * from member where password= '" + Password + "' and username= '" + username + "";
ResultSet rslogincheck = stmt_check.executequery (sql);
if (Rslogincheck.next ()) {
if (rslogincheck.getstring ("Qunx"). Equals ("1")) {
Cookies cookie=new Cookies ("username", Java.net.URLEncoder.encode (username, "gb2312"));
Cookie.setmaxage (1*24*60*60);
Response.addcookie (cookie); Write cookies
Out.print ("<script type=" Text/javascript "> Alert" ("Landing success!"); window.location.href= ' login.jsp?op=my '; </ Script> ");
}else{
Out.print ("<script type=" Text/javascript "> Alert" ("Your account is still under review!") "); window.location.href= ' login.jsp '; </script> ");
}
}else{
Out.print ("<script type= text/javascript" > Alert ("User name or password error!!! "); window.location.href= ' login.jsp '; </script> ");
}
Rslogincheck.close ();
Stmt_check.close ();
Conn.close ();
}
Cookie cookies[]=request.getcookies ();
Cookie Scookie=null;
String Svalue=null;
String Sname=null;
String Scname=null;
if (cookies.length>1) {
for (int i=1;i<cookies.length;i++) {
SCOOKIE=COOKIES[1];
Scname=java.net.urldecoder.decode (Scookie.getvalue (), "gb2312");
Out.print ("username is" +scookie.getname () + "" + "password is" +java.net.urldecoder.decode "(Scookie.getvalue ()," gb2312 ") +" </br > ");
//}
}
if (scname!=null) {
Statement stmt_u=conn.createstatement (resultset.type_scroll_sensitive,resultset.concur_updatable);
String SQLU = "SELECT * from member where username= '" + scname + "'";
ResultSet Rsu = Stmt_u.executequery (SQLU);
if (Rsu.next ()) {
%>
<body>
<% @include file= "head.jsp"%>
<table width= "1003" border= "0" align= "center" cellpadding= "0" cellspacing= "0" >
<tr>
<TD width= "rowspan=" 3 "style=" Background:url (images/leftbg.jpg) repeat-y right ">&nbsp;</td>
<TD style= "Background-repeat:repeat-x" valign= "Top" align= "Middle"
background= "Images/l_m_bg.jpg" "height=" 370 "><table style=" margin-top:10px; margin-bottom:30px "cellspacing=" 0 "
cellpadding= "0" width= "border=" 0 ">
<tbody>
<tr>
<td><img height= "alt=" "src=" images/u_zc_top.jpg "
Width= "706"/></td>
</tr>
<tr>
<TD align= "Middle" background= "images/n_zc_md.jpg" height= "" ><span
class= "f12red" style= "FONT-SIZE:14PX; Font-weight:bold; COLOR: #cccc00 "> My personal Information </span>
<form id= "MyForm" name= "MyForm"
action= "" method= "POST" >
<table class= "K1" style= "margin-top:10px; margin-bottom:15px "
cellspacing= "0" cellpadding= "8" width= "570" align= "center" border= "0" >
<tbody>
<tr>
<TD class= "F14black" align= "right" width= "" "Bgcolor=" "#f0f8ff"
height= "><table" cellspacing= "0" cellpadding= "0" width= "100%" border= "0" >
<tbody>
<tr>
<TD align= "Right" > Username:</td>
</tr>
</tbody>
</table></td>
<TD align= "left" width= "180" height= "a" ><%=rsu.getstring ("username")%> </td>
<TD class= "F12blue" align= "left" width= "248" bgcolor= "#fafafa" ></td>
</tr>
<tr>
<TD class= "k_hui_t" align= "right" bgcolor= "#f0f8ff" height= "" ><table cellspacing= "0" cellpadding= "0" width = "100%" border= "0" >
<tbody>
<tr>
<TD class= "F14black"
Align= "right" > Unit name:</td>
</tr>
</tbody>
</table></td>
<TD class= "k_hui_t" align= "left" > <%=rsu.getstring ("Company")%></td>
<TD class= "F12blue" align= "left" bgcolor= "#fafafa" ><span class= "Posterror" id= "Comerror" > </span> </td>
</tr>
<tr>
<TD class= "k_hui_t" align= "right" bgcolor= "#f0f8ff" height= "" ><table cellspacing= "0" cellpadding= "0" width = "100%" border= "0" >
<tbody>
<tr>
<TD class= "F14black" align= "right" > Contact person:</td>
</tr>
</tbody>
</table></td>
<TD class= "k_hui_t" align= "left" > <%=rsu.getstring ("Conname")%></td>
<TD class= "F12blue" align= "left" bgcolor= "#fafafa" ><span class= "Posterror" id= "Connameerror" > </span ></td>
</tr>
<tr>
<TD class= "k_hui_t" align= "right" bgcolor= "#f0f8ff" height= "" ><table cellspacing= "0" cellpadding= "0" width = "100%" border= "0" >
<tbody>
<tr>
<TD class= "F14black" align= "right" > Tel:</td>
</tr>
</tbody>
</table></td>
<TD class= "k_hui_t" align= "left" ><label>
<%=rsu.getstring ("tel")%>
</label></td>
<TD class= "F12blue" align= "left"
Bgcolor= "#fafafa" ><span class= "Posterror" id= "Telerror" > </span></td>
</tr>
<tr>
<TD class= "k_hui_t" align= "right" bgcolor= "#f0f8ff" height= "" ><table cellspacing= "0" cellpadding= "0" width = "100%" border= "0" >
<tbody>
<tr>
<TD class= "F14black"
Align= "Right" >E_mail:</td>
</tr>
</tbody>
</table></td>
<TD class= "k_hui_t" align= "left" ><label>
<%=rsu.getstring ("email")%>
</label></td>
<TD class= "F12blue" align= "left" bgcolor= "#fafafa" ><span class= "Posterror" id= "Emailerror" > </span ></td>
</tr>
<tr>
<TD class= "k_hui_t" align= "right" bgcolor= "#f0f8ff" height= "" ><table cellspacing= "0" cellpadding= "0" width = "100%" border= "0" >
<tbody>
<tr>
<TD class= "F14black" align= "right" > Contact address:</td>
</tr>
</tbody>
</table></td>
<TD class= "k_hui_t" align= "left" > <%=rsu.getstring ("Address")%> </td>
<TD class= "F12blue" align= "left" bgcolor= "#fafafa" ><span class= "Posterror" id= "Adderror" > </span> </td>
</tr>
<input type= "hidden" value= "<%=SCname%>" name= "Editname"/>
<tr>
<TD class= "k_hui_t" align= "right" bgcolor= "#f0f8ff" height= "" ><table cellspacing= "0" cellpadding= "0" width = "100%" border= "0" >
<tbody>
<tr>
<TD class= "F14black" align= "right" > Remarks <span
Class= "f12red": </span></td>
</tr>
</tbody>
</table></td>
<TD class= "k_hui_t" align= "left" colspan= "2" > <%=rsu.getstring ("Content")%></td>
</tr>
<tr>
<TD class= "k_hui_t" align= "right" bgcolor= "#f0f8ff" height= "" ><table cellspacing= "0" cellpadding= "0" width = "100%" border= "0" >
<tbody>
<tr>
<TD class= "F14black" align= "right" > Status <span
Class= "f12red": </span></td>
</tr>
</tbody>
</table></td>
<TD class= "k_hui_t" align= "left" colspan= "2" >
<% if (rsu.getstring ("Qunx"). Equals ("1")) {
Out.print ("audited");
}else{out.print ("<font color=" #ff0000 "> Awaiting Audit </font>");}
%></td>
</tr>
<tr>
<td></td>
<td><input type= "Submit" value= "Modify" name= "Editsubmit"/> <input type= "Submit" value= "Exit" Name= "DROPSU Bmit "/></td>
</tr>
</tbody>
</table>
</form></td>
</tr>
<tr>
<td><img height= "Notoginseng" alt= "src=" Images/n_zc_down.jpg "
Width= "706"/></td>
</tr>
</tbody>
</table></td>
<TD width= "rowspan=" 3 "style=" Background:url (images/rightbg.jpg) repeat-y left "> </td>
</tr>
</tbody>
</table>
<% @include file= "foot.jsp"%>
</body>
<%
}else{
Cookie Deletenewcookie=new Cookie ("username", null);
Deletenewcookie.setmaxage (0);
Response.addcookie (Deletenewcookie);
Response.sendredirect ("login.jsp");
}
Rsu.close ();
Stmt_u.close ();
return;
}else{
%>
<body>
<table cellspacing= "0" cellpadding= "0" width= "1002" border= "0" >
<tbody>
<tr>
<TD width= "1002" ><img height= "alt=" "src=" images/l_top.jpg "width=" "1002" border= "0"/></td>
</tr>
<tr>
<TD style= "background-position:50% bottom; Background-repeat:repeat-x "background=" images/i_topd.jpg "height=" >&nbsp;</td>
</tr>
<tr>
<TD style= "Background-repeat:repeat-x" valign= "Top" align= "Middle" background= "images/l_m_bg.jpg" height= "370" ><form action= "Login.jsp?action=add" method= "post" name= "MyForm" id= "MyForm" onsubmit= "return Check ()" >
<table style= "margin-top:15px" height= "278" cellspacing= "0" cellpadding= "0" width= "M" border= "0" >
<tbody>
<tr>
<TD valign= "Top" align= "Middle" colspan= "3" height= "a" ><img height= "14"
alt= "" "Src=" Images/i_sorry.jpg "width="/></td> "
</tr>
<tr>
<TD colspan= "3" ><img height= "alt=" "src=" images/n_tb_login.jpg "width=" 523 "/></td>"
</tr>
<tr>
<TD width= "height=" 175 "rowspan=" 2 "><img height=" 175 "alt=" "
Src= "Images/n_login_md.jpg" width= "/></td>"
<TD align= "Middle" width= "219" bgcolor= "#ffffff" height= "129" ><table cellspacing= "0" cellpadding= "0" width= " 100% "border=" 0 ">
<tbody>
<tr>
<TD class= "F14black" align= "right" width= "28%" height= "a" > Username:</td>
<TD align= "left" width= "72%" ><input class= "K1" onmouseover= "this.style.background= ' #E1F4EE ';" style= "width : 150px "onfocus=" This.select (); "onmouseout=" this.style.background= ' #FFFFFF ' "name=" username "/><br><span class=" Posterror "id=" Userror "> </span></td>
</tr>
<tr>
<TD class= "F14black" align= "right" height= "a" > Secret &nbsp;&nbsp; code:</td>
<TD align= "left" ><input class= "K1" onmouseover= "this.style.background= ' #E1F4EE"; "onfocus=" this.select (); "onmouseout=" this.style.background= ' #FFFFFF ' "type=" password "name=" password "/><br><span class=" Posterror "id=" Pserror "> </span></td>
</tr>
<tr>
<TD colspan= "2" height= "ten" ></td>
</tr>
<tr>
<TD align= "Middle" colspan= "2" ><a href= "reg.jsp" ><img height= "alt=" "src=" images/l_set_bt.jpg " Width= "border=" "0"/></a>&nbsp;&nbsp;&nbsp;
<input name= "image" type= "image" src= "images/l_login_bt.jpg" "alt=" "width=" "height=" "/></td>"
</tr><input type= "hidden" value= "true" name= "Logincheck"/>
</tbody>
</table></td>
<TD height= "rowspan=" 2 "><img height=" 175 "alt=" "src=" Images/l_lx.jpg "width=" 262 "/></td>"
</tr>
<tr>
<TD valign= "Bottom" ><img height= "alt=" "src=" Images/n_login_down.jpg "width=" 219 "/></td>"
</tr>
<tr>
<TD colspan= "3" >&nbsp;</td>
</tr>
</tbody>
</table>
</form></td>
</tr>
</tbody>
</table>
</body>
</html>
<%
}
Conn.close ();
%>