-
Notifications
You must be signed in to change notification settings - Fork 0
/
reg.jsp
67 lines (56 loc) · 1.65 KB
/
reg.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
63
64
65
66
67
<%@page import="java.sql.*,javax.sql.*,java.io.*"%>
<%@page import="java.io.*"%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@page import="java.sql.*,java.util.*"%>
<%! PreparedStatement ps;
ResultSet rs;
%>
<%
String first_name=request.getParameter("firstname");
String mid_name=request.getParameter("middlename");
String last_name=request.getParameter("surname");
String gender=request.getParameter("gender");
String YOS=request.getParameter("YOS");
String year=request.getParameter("year");
String dept=request.getParameter("dept");
String email=request.getParameter("email");
String pass=request.getParameter("pass");
String pass2=request.getParameter("pass2");
String strGender;
if(gender.equals("Female"))
{
strGender="Ms. ";
}
else
{
strGender="Mr. ";
}
String fullname=strGender+first_name+" "+mid_name+" "+last_name;
if(pass.equals(pass2))
{
try {
Class.forName("com.mysql.jdbc.Driver");
Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/dbname", "root", "password");
ps=conn.prepareStatement("insert into tablename(fullname,YOS,year,dept,gender,email,pass) values(?,?,?,?,?,?,?)");
ps.setString(1,fullname);
ps.setString(2,YOS);
ps.setString(3,year);
ps.setString(4,dept);
ps.setString(5,gender);
ps.setString(6,email);
ps.setString(7,pass);
int rows=ps.executeUpdate();
if(rows>0)
{
%>
<jsp:forward page="login.jsp">
<jsp:param name="message" value="sign up successful"/>
</jsp:forward>
<%}
}
catch(SQLException e) {
out.println("SQLException caught: " +e.getMessage());
}
}
%>