-
Notifications
You must be signed in to change notification settings - Fork 0
/
in.jsp
62 lines (46 loc) · 1.46 KB
/
in.jsp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<%@ page
language="java"
import = "java.io.*,java.sql.*,java.util.*"
%>
<%
String msg = null;
RequestDispatcher rd =request.getRequestDispatcher("mainUserHome.jsp");
String id = request.getParameter("pin");
String type=request.getParameter("UserType");
Class.forName("com.mysql.jdbc.Driver");
String url = "jdbc:mysql://127.0.0.1/bank";
Connection con=DriverManager.getConnection(url,"root","root");
Statement st=con.createStatement();
PreparedStatement pst=con.prepareStatement("Select * from user where id=? and type=? ");
pst.setString(1, id);
pst.setString(2, type);
ResultSet rsp = pst.executeQuery();
if(rsp.next())
{
String name=rsp.getString("firstname");
name+=" ";
name+=rsp.getString("lastname");
if(type.equals("true"))
{
rd = request.getRequestDispatcher("mainUserHome.jsp");
session.setAttribute("type",type);
session.setAttribute("id",id);
session.setAttribute("name",name);
session.setAttribute("log","in");
}
else
{
rd = request.getRequestDispatcher("otherUserHome.jsp");
session.setAttribute("type",type);
session.setAttribute("log","in");
session.setAttribute("name",name);
session.setAttribute("id",id);
}
rd.forward(request,response);
}
else
{
RequestDispatcher r1 = request.getRequestDispatcher("err.jsp?msg=Login Failed!");
r1.forward(request,response);
}
%>