-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadmin_signup.java
90 lines (78 loc) · 3.09 KB
/
admin_signup.java
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
import java.io.IOException;
import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.Statement;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
*
* @author lenovo1
*/
public class admin_signup extends HttpServlet
{
Connection cn=null;
Statement st=null;
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
PrintWriter out = resp.getWriter();
String name=req.getParameter("name");
String phno=req.getParameter("phno");
String email=req.getParameter("email");
String adminname=req.getParameter("adminname");
String password=req.getParameter("password");
String repassword=req.getParameter("repassword");
String event=req.getParameter("submit");
out.println(name);
out.println(phno);
out.println(email);
out.println(adminname);
out.println(password);
out.println(repassword);
out.println(event);
Database db = new Database();
String result = db.Connectdb();
out.println(result);
if(event.equals("SIGN-IN"))
{
if(name.equals("") || phno.equals("") || email.equals("")|| adminname.equals("") || password.equals("") || repassword.equals(""))
{
resp.setContentType("text/html");
out.println("<script type='text/javascript'>");
out.println("alert('Something is empty')");
out.println("location='admin_signup.jsp'");
out.println("</script>");
}
else
{
if(password.equals(repassword))
{
try
{
String sql = "insert into admin_signup(name, phno, email, adminname, password, repassword) values ('"+name+"', '"+phno+"' , '"+email+"', '"+adminname+"','"+password+"', '"+repassword+"')";
String insert = db.Insert(sql);
out.println(insert);
resp.setContentType("text/html");
out.println("<script type='text/javascript'>");
out.println("alert('Record Insert Succcessfully')");
out.println("location='admin_login.jsp'");
out.println("</script>");
}
catch(Exception ex)
{
out.println(ex.toString());
}
}
else
{
out.println("Password andConfirm password are not equal");
}
}
}
}
}