for store data in data base

Ads

 
 

Share on Google+Share on Google+

Rahul tenguriya
for store data in data base
3 Answer(s)      7 years ago
Posted in : JSP-Servlet
i want to a job site, in this site user can registered by a form..
in this form there are his information...
i use three form for it
1)for user name and password..
2)for personal detail...
3)for educational details..
by 1 and 2 i can move on three by continue.. button..
and on 3rd form i use submit button...
data of form 1 and 2 can also be store in table along with 3 form..
how can i do it... i use sql server2000
Ads
View Answers

April 20, 2010 at 3:44 PM


Hi Friend,

We have created 4 jsp files:

1)login.jsp:

<html>
<head>
<script src="valid.js" type="text/javascript"></script>
<style>
A:hover {
text-decoration: none;
font-family:arial;
font-size:12px;
color: #000000;
BORDER: none;
}
A {
text-decoration: underline;
font-family:arial;
font-size:12px;
color: #000000;
BORDER: none;
}
</style>
</head>
<body>
<br><br><br>
<form name="loginform" method="post" action="checklogin.jsp" >
<table width="250px" border=0 align="center" style="background-color:ffeeff;">
<tr>
<td colspan=2 align="center" style="font-weight:bold;font-size:20pt;" align="center">User Login</td>
</tr>
<tr>
<td colspan=2>&nbsp;</td>
</tr>
<tr>
<td style="font-size:12pt;" align="center">Login Name</td>
<td><input type="text" name="userName" value=""></td>
</tr>
<tr>
<td style="font-size:12pt;" align="center">Password</td>
<td><input type="password" name="password" value=""></td>
</tr>
<tr>
<td></td>
<td><input type="submit" name="Submit" value="Login"></td>
</tr>
<tr>
<td></td>
<td align="right"><a href="register.jsp">New User?</a></td>
</tr>
</table>
</form>


</body>
</html>

2)checklogin.jsp:

<%@ page language="java" import="java.sql.*;"%>
<html>
<body>
<%
String userName = request.getParameter("userName");
String password = request.getParameter("password");
try {
Class.forName("com.mysql.jdbc.Driver").newInstance();
Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/test","root","root";);
Statement st = conn.createStatement();
String strQuery = "select count(*) from login where username='"+userName+"' and password='"+password+"'";
out.println(strQuery);
ResultSet rs = st.executeQuery(strQuery);
if(rs.next()) {
if(rs.getInt(1)>0) {
session.setAttribute("userid",userName);
response.sendRedirect("details.jsp");
}
else
{
response.sendRedirect("checklogin.jsp");
}
}
System.out.println("Connected to the database");
conn.close();
System.out.println("Disconnected from database");
} catch (Exception e) {
e.printStackTrace();
}
%>
</body>
</html>


April 20, 2010 at 3:47 PM


continue..

3)register.jsp:

<%@ page import="java.sql.*"%>
<html>
<body>
<br>
<form name="userform" method="post" >
<table width="350px" border=0 align="center" style="background-color:ffeeff;">
<tr>
<td colspan=2 style="font-weight:bold;font-size:20pt;" align="center">User Registeration</td>
</tr><tr><td colspan=2>&nbsp;</td>
</tr><tr>
<td>First Name </td>
<td><input type="text" name="firstName" ></td>
</tr>
<tr>
<td>Last Name </td>
<td><input type="text" name="lastname"></td>
</tr>
<tr>
<td>Login Name</td>
<td><input type="text" name="userName" ></td>
</tr>
<tr>
<td>Password</td>
<td><input type="password" name="password" ></td>
</tr>
<tr>
<td>Email</td>
<td><input type="text" name="email" ></td>
</tr>
<tr>
<td>Address</td>
<td><textarea name="address" rows=5 cols=25></textarea></td>
</tr>
<tr>
<td>Contact No</td>
<td><input type="text" name="contactNo" ></td>
</tr>
<tr>
<td></td>
<td><input type="submit" name="Submit" value="Save"></td>
</tr>
</table>
</form>
</body>
</html>
<%String fname=request.getParameter("firstName");
String lname=request.getParameter("lastName");
String uname=request.getParameter("userName");
String password=request.getParameter("password");
String email=request.getParameter("email");
String address=request.getParameter("address");
String contact=request.getParameter("contactNo");
try {
Class.forName("com.mysql.jdbc.Driver").newInstance();
Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/test","root","root";);
Statement st = conn.createStatement();
int i=st.executeUpdate("insert into login(firstname,lastname,username,password,email,address,contactno) values('"+fname+"','"+lname+"','"+uname+"','"+password+"','"+email+"','"+address+"','"+contact+"')");
}
catch(Exception e){}
%>
<form name="form" action="details.jsp">

<table width="350px" border=0 align="center" style="background-color:ffeeff;">
<tr>
<td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td>
<td><input type="submit" value="continue" ></td></tr>
</table>
</form>


April 20, 2010 at 3:48 PM


continue..

4)details.jsp:

<%@ page import="java.sql.*"%>
<html>
<body>
<br>
<form method="post" >
<table width="350px" border=0 align="center" style="background-color:ffeeff;">
<tr>
<td colspan=2 style="font-weight:bold;font-size:20pt;" align="center">Education Details</td>
</tr>
<tr>
<td>Highest Qualification</td>
<td><input type="text" name="qualification" ></td>
</tr>
<tr>
<td>Specialization</td>
<td><input type="text" name="specialization"></td>
</tr>
<tr>
<td>Year Of Passing</td>
<td><input type="text" name="year" ></td>
</tr>
<tr>
<td>Institute</td>
<td><input type="text" name="institute" ></td>
</tr>
<tr>
<tr>
<td></td>
<td><input type="submit" name="Submit" value="Save Details"></td>
</tr>
</table>
</form>
</body>
</html>
<%String qua=request.getParameter("qualification");
String special=request.getParameter("specialization");
String year=request.getParameter("year");
String institute=request.getParameter("institute");
try {
Class.forName("com.mysql.jdbc.Driver").newInstance();
Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/test","root","root";);
Statement st = conn.createStatement();
int i=st.executeUpdate("insert into education(qualification,specialization,year,instatitute) values('"+qua+"','"+special+"','"+year+"','"+institute+"')");
}
catch(Exception e){}
%>
Thanks

Ads









Related Tutorials/Questions & Answers:
for store data in data base - JSP-Servlet
for store data in data base  i want to a job site, in this site user can registered by a form.. in this form there are his information... i use..... and on 3rd form i use submit button... data of form 1 and 2 can also be store
data base
data base  how to connect coding in data base ?   The given code connects JSP page to database. You need to import the mysql connection jar file to jdk as well as to the lib of tomcat. Moreover you need to set classpath
Advertisements
DATA BASE
DATA BASE  Create a program to establish a connection to the PCTBC... the data using a J Table.   Here is a code that connects to MySql... main(String[] args) { Vector columnNames = new Vector(); Vector data = new Vector
Store ResultSt Data in a Map
Store ResultSt Data in a Map  i want to store data in a hash Map .Please solve my problem as soon as possible
iPad App to store data
iPad App to store data  Hi, How to add data support iPad application? Thanks
store and retrieve data
store and retrieve data  sir,i want to store the entering data in a word file and retrieve it when i need.i am try to develop a video portal.in which... Write data into word file For this, poi-scratchpad-3.7-20101029.jar is needed
Data base Connectivity
Data base Connectivity  How to configure JDBC connection for Oracle data base.In configuring it is asking select Data server name and TNS.I typed Oracle for Data Server Name and IN TNS what to type? I pulled the list for TNS
Java Xml Data Store
be followed up and/or purchased. You will need to store the data in a local binary... the implementation needs to change later on (perhaps they might decide to store the data...Java Xml Data Store  I have to do this project and i'm finding it so
servlet program for data store in oracle?
servlet program for data store in oracle?  how to store data in oracle through servlet program
store form data into word document
store form data into word document  i want form page data, ex username phone number.. to store it in a word document file
Data base related question
Data base related question  sir my table has only one element(that is pno),i am using ms-access as backend. i put only one element i want to retrieve that element .how can i retrieve that element,using jdbc technology. please
JSP data base validation
JSP data base validation  please explain how to validate form input string with database n also how its notify that entered data exists already... bol = ps.execute(); out.println("Data Added Successfully
how to store,retrieve,modify the data
how to store,retrieve,modify the data  hello sir ,how to store,retrieve,modify the data using the swing please help me
Data base - JDBC
Data base  I want to do this Inserting a record with Object type column using PreparedStatement but wht should b the column datatype this is te..."); con.close(); }//main }//class For this should i create a user defined data type
to store data entered in html page
to store data entered in html page  i want to a job site... submit we have to move to form 2 on there we have enter text data in the textfield after that by clicking submit button data enter in form 1 and 2 should
store data from a variable in mysql?
store data from a variable in mysql?  sir last time asked you tell me how to retrieve data from a database mysql and store it in an int variable in order to apply some calculation on it, but now i want to store the result
J2ME Record Data Base
J2ME Record Data Base       This Application is used to explain how to store data in the database... the RecordStore class. The RecordStore class is used to get the data through
Retrive the data from the table in data base using jdbc
Retrive the data from the table in data base using jdbc  Retrive the data from the table in data base using jdbc   JDBC Tutorials
project in JSP and XML(to store data)
project in JSP and XML(to store data)  I need to complete an assignment in JSP and using XML as Database ,Please help me to complete this assignment.Ill be very very thankful to you,i am new to JSP.Please provide full code
please send me the banking data base in swings
please send me the banking data base in swings  sir, please send me how to create the banking data base program in swings
data (image ,audio) inserting to data base (oracle 10g) and retriving the same data from jsp
data (image ,audio) inserting to data base (oracle 10g) and retriving the same data from jsp   data (image ,audio) inserting to data base (oracle 10g) and retriving the same data from jsp with script of data base plz help me
JSP and XML .data store nd retrieve
JSP and XML .data store nd retrieve  I have made a form in jsp having emp id, projectname and emp name.I want to store data related to employee in xml file.How can i store data entered by user in XML file and later retrieve data
when refreshing the page the data is stored in data base again
when refreshing the page the data is stored in data base again  Hi, In my application, I am adding form data in database on click of submit button.But the problem is, when user refreshes the page, the data added one more time
Retrieving data from data base using jsp combo box
Retrieving data from data base using jsp combo box  Hi guys please help me , i have on GUI page int that Server type(like apache,jboss,weblogic) one combo box is there and another filed is version of the server(like 1.0,2.0) like
retrive data from data base and print it in every page until logout
retrive data from data base and print it in every page until logout  suppose that a user login your website through user name & password. now after completion of login he goto home page.inside home page i want to print
how to store data in XML file - JSP-Servlet
how to store data in XML file  hi i have to store the data for example user id and password in a xml file the input userid and password will be coming from jsp middle ware servlet how to do that?   Hi friend
data
data  Handling data
read text file and store the data in mysql - JDBC
read text file and store the data in mysql  when we store the data in mysql table from text file its store the data from new line to new column. how to store the data in different column from a single line of text file. 
data
data  data Handling AOP
data
data  Handling data in AOP
retrieve data from mysql database and store it in a variable ?
retrieve data from mysql database and store it in a variable ?  sir , I am working on a project , in which I have to apply operation on input data... to store that data in int variable. how to do this ?   Here is an example

Ads

 
Advertisement null

Ads