Jsp getting started Tutorial: User Login Password judgment code

Source: Internet
Author: User

Jsp getting started Tutorial: User Login Password judgment 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">
<Head>
<Meta name = "robots" content = "noindex, nofollow"/>
<Meta http-equiv = "Content-Type" content = "text/html; charset = gb2312"/>
<Title> logon check </title>
</Head>

<Body>
<%
String UserName = request. getParameter ("admin ");
String UserPwd = request. getParameter ("UserPassword ");
UserPwd = loginMD5.getMD5ofStr (UserPwd );
String rand = (String) session. getAttribute ("rand ");
String CheckCode = request. getParameter ("CheckCode ");
// String sel = request. getParameter ("sel_admin ");

Statement stmt_Check = conn. createStatement (ResultSet. TYPE_SCROLL_SENSITIVE, ResultSet. CONCUR_UPDATABLE );
String SQL = "select * from hl_admin where fPassword = '" + UserPwd + "' and fUserName = '" + UserName + "'";
ResultSet RsLoginCheck = stmt_Check.executeQuery (SQL );


If (RsLoginCheck. next ()){
If (rand. equals (CheckCode )){
// Out. print ("successful ");
Session. setAttribute ("AdminName", UserName );
Session. setAttribute ("Aforder", RsLoginCheck. getString ("forder "));
// If (sel. equals ("2 ")){
// Response. sendRedirect ("../enadmin/Ad_Index.jsp ");
//} Else {
Response. sendRedirect ("Ad_Index.jsp ");
//}
}
Else
{
Out. print ("the confirmation code you entered is inconsistent with the one generated by the system. Please enter it again. ");
}
}
Else
{
Out. print ("the user name or password is incorrect !!! ");
}
%>


<Br/>
========================

</Body>
</Html>
</Body>
</Html>
<%
RsLoginCheck. close ();
Stmt_Check.close ();
Conn. close ();
%>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.