gautamshetkar
edit data
2 Answer(s)      2 years and a month ago
Posted in : JSP-Servlet

sir i want to do edit a particular customers information after he logs in, i am also using sessions. thank you

View Answers

April 1, 2011 at 3:41 PM


1)login.jsp:

<html>
<script>
function validate(){
var username=document.form.user.value;
var password=document.form.pass.value;
if(username==""){
 alert("Enter Username!");
  return false;
}
if(password==""){
 alert("Enter Password!");
  return false;
}
return true;
}
</script>
<form name="form" method="post" action="check.jsp" onsubmit="javascript:return validate();">
<table>
<tr><td>Username:</td><td><input type="text" name="user"></td></tr>
<tr><td>Password:</td><td><input type="password" name="pass"></td></tr>
<tr><td></td><td><input type="submit" value="Submit"></td></tr>
</table>
</form>
</html>

2)check.jsp:

<%@page import="java.sql.*"%>

<%
String user=request.getParameter("user");
String pass=request.getParameter("pass");
 Class.forName("com.mysql.jdbc.Driver").newInstance();
    Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3306/test","root","root");  
           Statement st=con.createStatement();
           ResultSet rs=st.executeQuery("select * from login where username='"+user+"' and password='"+pass+"'");
int count=0;
int id=0;
          while(rs.next())
          {
            id=rs.getInt("id");
                   count++;
          }

                    if(count>0)
          {
            out.println("welcome "+user);
            %>
<a href="edit.jsp?id=<%=id%>">Edit Profile</a>
            <%
          }
          else
          {
                       response.sendRedirect("login.jsp?msg=Invalid Username or Password");
          }
%>

3)edit.jsp:

<%@page language="java"%>
<%@page import="java.sql.*"%>
<form method="post" action="update.jsp">
<table>
<%
String id=request.getParameter("id");
int no=Integer.parseInt(id);
int sumcount=0;
try {
Class.forName("com.mysql.jdbc.Driver").newInstance();
Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/test", "root", "root");
String query = "select * from login where id='"+no+"'";
Statement st = conn.createStatement();
ResultSet rs = st.executeQuery(query);
if(rs.next()){
%>
<tr><td>User Name:</td><td><input type="text" name="name" value="<%=rs.getString("username")%>"></td></tr>
<tr><td>Address:</td><td><input type="text" name="address" value="<%=rs.getString("address")%>"></td></tr>
<tr><td>Email:</td><td><input type="text" name="email" value="<%=rs.getString("email")%>"></td></tr>
<tr><td>Contact No:</td><td><input type="text" name="contact" value="<%=rs.getString("contactNo")%>"></td></tr>
<tr><td><input type="hidden" name="id" value="<%=rs.getString(1)%>"></td></tr>

<%
}
%>
<tr><td><input type="submit" name="Submit" value="Update" style="background-color:#49743D;font-weight:bold;color:#ffffff;"></td>
</tr>
<%
}
catch(Exception e){}
%>
</table>
</form>

April 1, 2011 at 3:41 PM


4)update.jsp:

<%@page import="java.sql.*"%>
<%
String ide=request.getParameter("id");
int num=Integer.parseInt(ide);
String name=request.getParameter("name");
String address=request.getParameter("address");
int contact=Integer.parseInt(request.getParameter("contact"));
String email=request.getParameter("email");
try{
Connection conn = null;
Class.forName("com.mysql.jdbc.Driver").newInstance();
conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/test","root", "root");
Statement st=null;
st=conn.createStatement();
st.executeUpdate("update login set username='"+name+"',address='"+address+"',contactNo="+contact+",email='"+email+"' where id='"+num+"'");
}
catch(Exception e){
System.out.println(e);
}
%>









Related Pages:
edit data
edit data  sir i want to do edit a particular customers information after he logs in, i am also using sessions. thank you
Update / Edit data
Update / Edit data  Hello, i want to create a page to edit or update user data in the data base. the thing is, when i click on submit reference number, i want the data for that reference no to automatically appear in the form
Edit the record.
that particular record.after editing the data i want to edit another row which is next... or some email.according to the sorted page we should fetch the data and edit...Edit the record.  sir, I have a table consist of huge data.I have
data grid with edit and delete options at each row.
data grid with edit and delete options at each row.  i want to display the table data in the format of data grid with edit and delete options at each row. i need it very urgently. advance thanks
Delete and edit data in xml file using JSP
Delete and edit data in xml file using JSP   I want to know how to delete and edit data from an XML file by use of JSP. I have XML file having tasks... in the xml file,I want to delete and edit some tasks using task id then how can i do
jsp :how to edit table of data displayed using jsp when clicked on edit button
jsp :how to edit table of data displayed using jsp when clicked on edit button  i have a jsp program which displays data in the form of table ..now i... the data when clicked on save button.. how can i do
jsp :how to edit table of data displayed using jsp when clicked on edit button
jsp :how to edit table of data displayed using jsp when clicked on edit button  i have a jsp program which displays data in the form of table ..now i... the particular edit button, that data will get shown in another page and allow the user
Dojo Inline Edit Box
Dojo Inline Edit Box          In this section, you will learn how to edit any data. The InlineEditBox provides the better facility for editing any data and save it.  Try
insert , edit , and delete button in one jsp page
insert , edit , and delete button in one jsp page  hello I want to ask about the way of creating a jsp page contains insert , edit , and delete buttons and manipulate data in database directly. any help please or hints
Non-edit Combobox with auto fill - Swing AWT
Non-edit Combobox with auto fill  Hi, I have a non-edit... typed by the user. For example, ["Callisto", "Charls", "chim"] are the data... the characters typed by the user in Document(Model for Edit view of the JCombobox
How to save image after edit in php
How to save image after edit in php  Hello, I have create a simple image editor with the effected of brightness, contrast, and desaturat etc. I have...;body> <form name="form1" action="index.php" enctype="multipart/form-data
Add Edit And Delete Employee Information
Add Edit and Delete Employee Information Using Swing  ..., edit and delete the Employee's information from the database using java swing... information into the database. The second tab will edit the Employee's information
Edit Distance
Edit Distance  I want java programming ask from user input two string and the program find the edit distance between two strings and find table and optimal solution using GUI
How to edit values in textboxes from database using jsp
How to edit values in textboxes from database using jsp  Hi RoseIndia, I need help to solve my technical problem, i want to edit values in textboxes...:bold;" align="center">Edit User</td></tr> <tr><
data update
data update  sir, I have a table consist of huge data.I have displayed that data in table format be side of a table an edit button which will edit... the data and edit it based on subjectcode(varchar)this should be done using jsp
data update
data update  sir, I have a table consist of huge data.I have displayed that data in table format be side of a table an edit button which will edit... the data and edit it based on subjectcode(varchar)this should be done using jsp
data update
data update  sir, I have a table consist of huge data.I have displayed that data in table format be side of a table an edit button which will edit... the data and edit it based on subjectcode(varchar)this should be done using jsp
data update
data update  sir, I have a table consist of huge data.I have displayed that data in table format be side of a table an edit button which will edit... the data and edit it based on subjectcode(varchar)this should be done using jsp
data update
data update  sir, I have a table consist of huge data.I have displayed that data in table format be side of a table an edit button which will edit... the data and edit it based on subjectcode(varchar)this should be done using jsp
data update
data update  sir, I have a table consist of huge data.I have displayed that data in table format be side of a table an edit button which will edit... the data and edit it based on subjectcode(varchar)this should be done using jsp
data update
data update  sir, I have a table consist of huge data.I have displayed that data in table format be side of a table an edit button which will edit... the data and edit it based on subjectcode(varchar)this should be done using jsp
data update
displayed that data in table format be side of a table an edit button which will edit... the data and edit it based on subjectcode(varchar)this should be done using jsp... edit/update data and saved them into that table again
Dojo Inline Edit Box
to edit any data. The InlineEditBox provides the better facility for editing any data...Dojo Inline Edit Box      ... the role as a <div> tag when not in edit mode. When you click widget text
Dojo Inline Edit Box
to edit any data. The InlineEditBox provides the better facility for editing any data...Dojo Inline Edit Box      ... the role as a <div> tag when not in edit mode. When you click widget text
Edit image - XML
Edit image  How to edit my Image Document Online?  Just visit http://www.onlinedocumentconversion.com/ and register there, upload and convert your image
how to edit a record in hibernate?
how to edit a record in hibernate?  how to edit a record in hibernate?   Hi Friend, Please visit the following link: Hibernate Tutorials Thanks   Hi Friend, Please visit the following link: Hibernate
Edit cron entry
Edit cron entry   Hi, What is the command to Edit cron entry in linux? Regards Deepak Kumar   Hi, You can use the following command to open cron configuration in vi editor: crontab -e After editing just save
UINavigationBar Edit Button
UINavigationBar Edit Button  UINavigationBar Edit Button Given is the code that adds a edit button item as a nav bar item in your UINavigation Controller. -(void)viewDidLoad; { [super viewDidLoad]; UINavigationBar* navBar
Edit Text by Insertion and Replacement
Edit Text by Insertion and Replacement   ..., " Rohini "):- This is a method to insert data in the text node. Here...;):- This is a method to replace data in the text node. here 13 specifies value
uitableview edit done button
uitableview edit done button  How to add Edit / Done button in UITableView with an action on click?   UITableview Edit done Button To add " Edit / Done button " in UITableView add the given code in UIView Controller
delete and edit options in struts
delete and edit options in struts   Hi, I am doing an web application... errors but the edit and delete operations were not working, so please modify my...;!-- end of Update Stock items --> <!-- get items to Edit -->
delete and edit options in struts
delete and edit options in struts  Hi, I am doing an web application using struts, jsp, tomcat server, oracle as a database in netbeans IDE 7.1.2, I... errors but the edit and delete operations were not working, so please modify my
delete and edit options in struts
delete and edit options in struts  Hi, I am doing an web application using struts, jsp, tomcat server, oracle as a database in netbeans IDE 7.1.2, I... errors but the edit and delete operations were not working, so please modify my
delete and edit options in struts
delete and edit options in struts  Hi, I am doing an web application using struts, jsp, tomcat server, oracle as a database in netbeans IDE 7.1.2, I... errors but the edit and delete operations were not working, so please modify my
delete and edit options in struts
delete and edit options in struts  Hi, I am doing an web application using struts, jsp, tomcat server, oracle as a database in netbeans IDE 7.1.2, I... errors but the edit and delete operations were not working, so please modify my
delete and edit options in struts
delete and edit options in struts  Hi, I am doing an web application using struts, jsp, tomcat server, oracle as a database in netbeans IDE 7.1.2, I... errors but the edit and delete operations were not working, so please modify my
delete and edit options in struts
delete and edit options in struts  Hi, I am doing an web application using struts, jsp, tomcat server, oracle as a database in netbeans IDE 7.1.2, I... errors but the edit and delete operations were not working, so please modify my
delete and edit options in struts
delete and edit options in struts  Hi, I am doing an web application using struts, jsp, tomcat server, oracle as a database in netbeans IDE 7.1.2, I... errors but the edit and delete operations were not working, so please modify my
delete and edit options in struts
delete and edit options in struts  Hi, I am doing an web application using struts, jsp, tomcat server, oracle as a database in netbeans IDE 7.1.2, I... errors but the edit and delete operations were not working, so please modify my
delete and edit options in struts
delete and edit options in struts  Hi, I am doing an web application using struts, jsp, tomcat server, oracle as a database in netbeans IDE 7.1.2, I... errors but the edit and delete operations were not working, so please modify my
delete and edit options in struts
delete and edit options in struts  Hi, I am doing an web application using struts, jsp, tomcat server, oracle as a database in netbeans IDE 7.1.2, I... errors but the edit and delete operations were not working, so please modify my
edit values of database using jsp
edit values of database using jsp  hi i want a code to edit the row from tye database and display in a page which containd radio buttons and drop down boxes using jsp code
edit values of database using jsp
edit values of database using jsp  hi i want a code to edit the row from tye database and display in a page which containd radio buttons and drop down boxes using jsp code
ZF Data Update in DB
Edit Record in Zend Framework: Now if someone wants to change, update or edit any record then the required settings and coding are given below, as usual... ..... public function editAction() { $this->view->title = "Edit
radio button value on edit action
radio button value on edit action  This is my edit.jsp code...In my... provided show edit add and delete link for each customer that is searched...Problem 'm facing is on edit action 'm not retrieving radio button value..i have
edit the flash video file using html5
edit the flash video file using html5  hi iam vivek i have a flash file i want to edit it with html5 please reply
data formatters temporarily unavailable xcode
data formatters temporarily unavailable xcode  In my iPhone application when i choose to edit the captured image i get error saying... data formatters temporarily unavailable in xcode. What is this error and how can i remove
Java JTable
to store, show and edit the data in tabular format. It displays tables of data, optionally allowing the user to edit the data. JTable does not contain or cache data; it is simply a view of your data. The Java swing implements tables by using
edit msword file - using java - Java Beginners
edit msword file - using java  I want to edit ms word file. That is input file font style is times new romen and font size is 12. I want the output file font style is bookman old style and size is 20. How to possible java
Block edit menu option - JSP-Servlet
Block edit menu option  I am doing a jsp project. I have to control number of characters in a text area upto a limit. How can i block pasting through edit menu and pasting through short cut key [ctrl+v

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.