-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlogchk.jsp
60 lines (59 loc) · 1.84 KB
/
logchk.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
<title>Validating...</title>
<%@page import="java.sql.*"%>
<%@page import="agri.dbconnect"%>
<jsp:useBean id="s" class="agri.dbconnect"/>
<jsp:getProperty name="s" property="conn"/>
<%
String chk=request.getParameter("valid");
if(chk!=null)
{
String un=request.getParameter("uname");
String ps=request.getParameter("pass");
ResultSet rs=s.stm.executeQuery("select * from login where username='"+un+"'");
if(rs.next())
{
ResultSet rs1=s.stm.executeQuery("select * from login where username='"+un+"' and Password='"+ps+"'");
if(rs1.next())
{
ResultSet rs2=s.stm.executeQuery("select * from login where username='"+un+"' and Password='"+ps+"' and status='active'");
if(rs2.next())
{
String utp=rs2.getString("utype");
session.setAttribute("uname",un);
if(utp.equals("admin"))
{
response.sendRedirect("admin/home.jsp");
}
else if(utp.equals("officer"))
{
response.sendRedirect("officer/home.jsp");
}
else if(utp.equals("farmer"))
{
response.sendRedirect("farmer/home.jsp");
}
else
{
out.println("<script>alert('Invalid module');document.location='index.jsp';</script>");
}
}
else
{
out.println("<script>alert('In-active account. try later');document.location='index.jsp';</script>");
}
}
else
{
out.println("<script>alert('Invalid or wrong password');document.location='index.jsp';</script>");
}
}
else
{
out.println("<script>alert('Invalid username or username not found...!');document.location='index.jsp';</script>");
}
}
else
{
out.println("<script>history.back();</script>");
}
%>