-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvalidate.jsp
61 lines (55 loc) · 1.77 KB
/
validate.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
<%@ page import="javax.util.*" %>
<%@ page import="java.util.*" %>
<%@ page import="javax.sql.*" %>
<%@ page import="java.sql.*" %>
<%
String s1=request.getParameter("email");
String s2=request.getParameter("pass");
try{
Class.forName("com.mysql.jdbc.Driver");
Connection conn=DriverManager.getConnection("jdbc:mysql://localhost:3306/cip","root","");
Statement st=conn.createStatement();
//String queryString = "SELECT name,pass FROM signup where user='"+s1+"' and pass='"+s2+"'";
//ResultSet results = st.executeQuery(queryString);
//if(!results.next()) {
// out.println("Wrong Username and Password.");
// }
//else
//{
// out.println("Validated.");
//}
/*boolean flag = false;
String queryString = "select user,pass from signup";
ResultSet results = st.executeQuery(queryString);
while (results.next()) {
String name = results.getString("user");
String password = results.getString("pass");
if ((s1.equals(name)) && (s2.equals(password))) {
flag = true;
out.println("Username and Password exist");
}
results.close();
if(!flag){
out.println("Please Check Username and Password ");
}
}
*/
ResultSet rs=st.executeQuery("select * from signup where user='"+s1+"' and pass='"+s2+"'");
int count=0;
while(rs.next()){
count++;
}
if(count>0){
out.println("welcome "+s1);
response.sendRedirect("http://localhost:8080/booking/booking.html");
}
else{
response.sendRedirect("http://localhost:8080/Login/index.html");
}
}
catch(Exception e)
{
System.out.print(e);
e.printStackTrace();
}
%>