Abby希望大家帮助自己看清错误,我真的看了很久很久了,拜托各位高手出手相助啊
edi.html主页中有关用户登录的代码:
...
<title>Company Home</title>
<script language="JavaScript">
fuction isValid(LoginForm){
if(LoginForm.userName.value==""){
alert("登录名不能为空!");
return false;
}
else if((LoginForm.Password.length<6)||(LoginForm.Password.length>12)){
alert("密码必须是6-12位字母或数字!");
return false;
}
else if(LoginForm.Password.length()==0){
alert("密码不能为空!");
return false;
}
else{
return true;
}
}
</script></head>
。。。
<td height="246"><%String getmessage=(String) session.getValue("login_message");if (getmessage==null) getmessage="";%>
<form action="login_confirm.jsp" method="post" name="LoginForm" onSubmit="return isValid(this);">
<div align="right">
<p align="left">用户名:<input name="userName" type="text" value="---请输入您的用户名---">
<br>
<br>
密 码:<input name="Password" type="password" value="请输入您的密码">
<br>
<br>
<input type="submit" name="Submit" value="登录">
<label>
<input type="submit" name="Reset" value="重置">
</label>
</p>
<p>新用户注册 找回密码</p>
</div>
</form></td>
以下是login_confirm(登录验证)的代码:
<body>
<%
String driver="sun.jdbc.odbc.JdbcOdbcDriver";
Class.forName(driver).newInstance();
Connection con=null;
con=DriverManager.getConnection("jdbc:odbc:EnterpriseDatabaseInformation","","");
Statement stmt=null;
stmt=con.createStatement();
String username=request.getParameter("userName");
String password=request.getParameter("Password");
try{
ResultSet rs=con.executeQuery("select * from users where UserName='"+username"' and freeze=0");
if(rs.next()){
String PWD=request.getParameter("Password");
if(PWD.equals(rs.getString("Password"))){//判断用户输入的密码是否正确
session.setAttribute("username",username);//为session变量username赋值
response.sendRedirect("edi.html");//将页面重定向到主页面
}
else{out.println("<script language='javascript'>alert('您输入的用户名或密码有误,请与管理员联系!');window.location.href='edi.html';</script>");}
}
else{out.println("<script language='javascript'>alert('您输入的用户名或密码有误,或您的帐户已经被冻结,请与管理员联系!');window.location.href='edi.html';</script>");}
}
catch(Exception e){out.println("<script language='javascript'>alert('您的操作有误!');window.location.href='edi.html';</script>");}
con.close();
rs.close();
stmt.close();
session.putValue("UserName",username);%>
}
else{
rs.close();
stmt.close();
con.close();
String msg="登录名或者口令有误!";
session.putValue("login_message",msg);
%>
<script language="JavaScript">
window.location="passthrough.jsp?showword=登录"
</script>
<%}
<jsp:forward page="edi.html"/>
<%}%>
</body>