Using SQL Server to verify the user name and password, the user name and password entered from the page match the database user name and password, correct log in, error alerts.
<Form action="Index. jsp "method="POST"> <!--Large div Frame start- up<Div ID="Div"> <!--left Div frame start --<Div ID="Div1"> <P Style="Margin-left: 30px; "><IMG SRC="Image/Login/Vjia.gif "></Img></P> <div style="Width:350px;height:20px;margin-left: 30px;margin-Top:-10px "> <P><hr/></P> </Div> <P Style="Margin-Top: 0px;margin-left: 30px "><IMG SRC="Image/Red_btn.gif "></Img></P> <P Style="Margin-Top:-35px;margin-left: 40px;color: #fff; font-Size:12px;align:center ">Vjia Users</P> <P Style="Margin-Top:-28px;margin-left: 110px "><IMG SRC="Image/Btn_long.gif "></Img></P> <P Style="Margin-Top:-35px;margin-left: 120px;font-Size:12px ">VANCL Users</P> <div style="Width:350px;height:20px;margin-left: 30px;margin-Top:-8px "> <P><hr/></P> </Div> <P Style="Margin-left: 60px ">User name:<input type="text"Name="UserName"></P> <P Style="Margin-left: 75px ">Password:<input type="Password" name="Password"></P> <P Style="Margin-left: 150px;margin-Top: 10px "><input type="Submit" value="" Style="Width:65px;height:26px;background:url (Image/Tu2.gif) "></P> <P Style="Margin-left: 30px;margin-Top: 30px;margin-right: 80px ">Log in to Vjia using your partner account:<IMG SRC="Image/Account_qq.gif "></Img></P> <P Style="Margin-left: 30px;margin-Top: 0px;color:red;font-Weight:bold ">Warm tips:</P> <P Style="text-Indent:3em;font-Size:14px ">If you have not registered the Vjia user, you can log in using the VANCL username and the system will automatically register a Vjia account associated with your VANCL account when you log in. You can share Vancl loyalty points and spending amounts after the account is linked.</P> <P Style="Margin-Top: 30px;margin-left: 100px ">If you have any questions, please click here<Font style=The font-Weight:bold ">Help Center</Font>Or<Font style=The font-Weight:bold ">Contact Customer Service</Font></P></Div></Form>
<%@ Page Language="Java" Import="Java.util.*"Pageencoding="UTF-8"%><%@pageImport="Java.sql.Connection"%><%@pageImport="Java.sql.PreparedStatement"%><%@pageImport="Java.sql.ResultSet"%><%@pageImport="Jdbc.sqlserver"%><%String UserName=request.getparameter ("UserName"); UserName=New String (Username.getbytes ("ISO-8859-1")," utf-8"); String Password=request.getparameter ("password"); //Reference Connection database method SQL Server sq=new SQL Server (); //Get database connection Connection con=sq.getconnection (); //write SQL statement String SQL="Select * fromAdminwhereUserName=? andPassword=? "; //Get database Operations Object PreparedStatement St=NULL; St=con.preparestatement (SQL); St.setstring (1, UserName); St.setstring (2, password); //Get result set ResultSet RS=NULL; RS=St.executequery (); if(Rs.Next()) {session.setattribute ("url", userName); %> <Script type="text/JavaScript>alert ("Log in Success"); Location="jiehe.jsp"; </Script> <% }Else{ %> <Script type="text/JavaScript>alert ("Please register first, then log in"); Location="dolog.jsp"; </Script> <% } //Frees Resource Sq. Shifang (Rs,st,con); %>
Verifying the user name and password with SQL Server