zero_shubham1

jsp

Jan 23rd, 2019
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 2.84 KB | None | 0 0
  1. <%--
  2.    Document   : index
  3.    Created on : Oct 20, 2018, 6:47:25 PM
  4.    Author     : Admin
  5. --%>
  6.  
  7. <%@page contentType="text/html" pageEncoding="UTF-8"%>
  8. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
  9.   "http://www.w3.org/TR/html4/loose.dtd">
  10.    <html>
  11.  
  12.         <head>
  13.             <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  14.             <link rel="stylesheet" href="css/secondary.css">
  15.             <title>Re-registration login</title>
  16.         </head>
  17.         <body>
  18.  
  19.             <div class="info-section">
  20.  
  21.                 <h1 id="info-section-head">Login Status:</h1>
  22.                 <%@page contentType="text/html" %>
  23.  
  24.         <%@page import="javax.naming.*" %>
  25.         <%@page import="java.sql.*" %>
  26.         <%@page import="javax.sql.*" %>
  27.  
  28.         <%
  29.        String enroll = "";
  30.        Connection conn=null;
  31.        Statement stmt=null;
  32.        ResultSet rs=null;
  33.        int flag = 0;
  34.        try{
  35.            Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
  36.            conn=DriverManager.getConnection("jdbc:odbc:mydsn");
  37.            enroll = request.getParameter("enroll");
  38.            String pass = request.getParameter("pass");
  39.            session.setAttribute("enrolls",enroll);
  40.            stmt=conn.createStatement();
  41.            rs=stmt.executeQuery("select * from Table1 where EnrollmentNum='"+enroll+"'");
  42.            //System.out.println(cid);
  43.  
  44.            while(rs.next()){
  45.            String ps = rs.getString("Password");
  46.            if(ps.equals(pass))
  47.                flag = 1;
  48.            }
  49.  
  50.            rs.close();
  51.            rs=null;
  52.            stmt.close();
  53.            stmt=null;
  54.            conn.close();
  55.            conn=null;
  56.  
  57.            
  58.            }
  59.            catch(SQLException e){
  60.                out.println("Throw e"+e);
  61.            }
  62.  
  63.        if(flag==1){
  64.            out.println("<span class='success'>Credentials matched, you're logged in! Enter below details to re-register.</span>");
  65.         }
  66.         %>
  67.                 <%
  68.                if(flag==1){
  69.                    out.println("<form method='POST' action='submit.jsp'><div class='form__group'><input name='draft-num' type='tel' class='form__input' placeholder='Draft number' id='draftnum' pattern='[0-9]+' maxlength='15' minlength='9' required ></div> <div class='form__group'> <input name='amt' type='tel' class='form__input' placeholder='Amount' id='pass' minlength='3' required> </div><div class='form__group'> <button type='submit' class='form__btn' id='form__btn-reReg'>Submit</button>    </div> </form>");
  70.                 }
  71.                 else{
  72.                     out.println("<span class='fail'></span>Credentials did not match, please try again! <a href=index.html>Go back.</a></span>");
  73.                 }
  74.                 %>
  75.  
  76.             </div>
  77.  
  78.         </body>
  79.     </html>
Add Comment
Please, Sign In to add comment