<%@ page import ="java.sql.*"%>
<%@page import="com.connection.DBConnection"%>
<%@page import="java.util.Date"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<%
try{
String fnm=request.getParameter("fname");
String lnm=request.getParameter("lname");
String eml=request.getParameter("email");
String phn=request.getParameter("phone");
String pass=request.getParameter("password");
String city=request.getParameter("city");
String add=request.getParameter("address");
String dbURL = "jdbc:mysql://localhost:3306/food4u";
String username="root";
String password="root";
Class.forName("com.mysql.jdbc.Driver");//load driver
Connection con2 = DriverManager.getConnection(dbURL, username, password);
System.out.println("test");
String query="insert into restaurent(fname,lname,email,phone,pass,city,adds) values(?,?,?,?,?,?,?)";
PreparedStatement pst=con2.prepareStatement(query);
pst.setString(1,"fnm");
pst.setString(2,"lnm");
pst.setString(3,"eml");
pst.setString(4,"phn");
pst.setString(5,"pass");
pst.setString(6,"city");
pst.setString(7,"adds");
pst.executeUpdate();
out.print("succefully add");
response.sendRedirect("login.jsp");
con2.close();
}
catch(SQLException e){
out.println(e);
e.printStackTrace();
}
%>
</body>
</html>
<%@page import="com.connection.DBConnection"%>
<%@page import="java.util.Date"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<%
try{
String fnm=request.getParameter("fname");
String lnm=request.getParameter("lname");
String eml=request.getParameter("email");
String phn=request.getParameter("phone");
String pass=request.getParameter("password");
String city=request.getParameter("city");
String add=request.getParameter("address");
String dbURL = "jdbc:mysql://localhost:3306/food4u";
String username="root";
String password="root";
Class.forName("com.mysql.jdbc.Driver");//load driver
Connection con2 = DriverManager.getConnection(dbURL, username, password);
System.out.println("test");
String query="insert into restaurent(fname,lname,email,phone,pass,city,adds) values(?,?,?,?,?,?,?)";
PreparedStatement pst=con2.prepareStatement(query);
pst.setString(1,"fnm");
pst.setString(2,"lnm");
pst.setString(3,"eml");
pst.setString(4,"phn");
pst.setString(5,"pass");
pst.setString(6,"city");
pst.setString(7,"adds");
pst.executeUpdate();
out.print("succefully add");
response.sendRedirect("login.jsp");
con2.close();
}
catch(SQLException e){
out.println(e);
e.printStackTrace();
}
%>
</body>
</html>
0 Comments