edit data

Ads
 

edit data

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);
}
%>

Ads









Related Tutorials/Questions & Answers:
importing data and edit that data
importing data and edit that data   hello sir i have data in excel sheet which contain 2 rows and i want to import that data to ms access and edit that data like adding new columns and new rows and creating new tables
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
Advertisements
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
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
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
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
ModuleNotFoundError: No module named 'edit'
ModuleNotFoundError: No module named 'edit'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'edit' How to remove the ModuleNotFoundError: No module named 'edit' error
ModuleNotFoundError: No module named 'edit'
ModuleNotFoundError: No module named 'edit'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'edit' How to remove the ModuleNotFoundError: No module named 'edit' error
ModuleNotFoundError: No module named 'edit'
ModuleNotFoundError: No module named 'edit'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'edit' How to remove the ModuleNotFoundError: No module named 'edit' error
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
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
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
data
data  Handling data
data
data  data Handling AOP
data
data  Handling data in AOP
ModuleNotFoundError: No module named 'apyref-edit'
ModuleNotFoundError: No module named 'apyref-edit'  Hi, My Python... 'apyref-edit' How to remove the ModuleNotFoundError: No module named 'apyref-edit' error? Thanks   Hi, In your python environment
ModuleNotFoundError: No module named 'config_edit'
ModuleNotFoundError: No module named 'config_edit'  Hi, My Python... 'config_edit' How to remove the ModuleNotFoundError: No module named 'config_edit' error? Thanks   Hi, In your python environment
ModuleNotFoundError: No module named 'config_edit'
ModuleNotFoundError: No module named 'config_edit'  Hi, My Python... 'config_edit' How to remove the ModuleNotFoundError: No module named 'config_edit' error? Thanks   Hi, In your python environment
ModuleNotFoundError: No module named 'dir-edit'
ModuleNotFoundError: No module named 'dir-edit'  Hi, My Python...-edit' How to remove the ModuleNotFoundError: No module named 'dir-edit... to install padas library. You can install dir-edit python with following
ModuleNotFoundError: No module named 'dvha-edit'
ModuleNotFoundError: No module named 'dvha-edit'  Hi, My Python... 'dvha-edit' How to remove the ModuleNotFoundError: No module named 'dvha-edit' error? Thanks   Hi, In your python environment you
ModuleNotFoundError: No module named 'edit-distance'
ModuleNotFoundError: No module named 'edit-distance'  Hi, My... 'edit-distance' How to remove the ModuleNotFoundError: No module named 'edit-distance' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'edit-distance-lte1'
ModuleNotFoundError: No module named 'edit-distance-lte1'  Hi, My... named 'edit-distance-lte1' How to remove the ModuleNotFoundError: No module named 'edit-distance-lte1' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'edit-distance'
ModuleNotFoundError: No module named 'edit-distance'  Hi, My... 'edit-distance' How to remove the ModuleNotFoundError: No module named 'edit-distance' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'edit-distance-lte1'
ModuleNotFoundError: No module named 'edit-distance-lte1'  Hi, My... named 'edit-distance-lte1' How to remove the ModuleNotFoundError: No module named 'edit-distance-lte1' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'hwit-edit'
ModuleNotFoundError: No module named 'hwit-edit'  Hi, My Python... 'hwit-edit' How to remove the ModuleNotFoundError: No module named 'hwit-edit' error? Thanks   Hi, In your python environment you
ModuleNotFoundError: No module named 'jaml-edit'
ModuleNotFoundError: No module named 'jaml-edit'  Hi, My Python... 'jaml-edit' How to remove the ModuleNotFoundError: No module named 'jaml-edit' error? Thanks   Hi, In your python environment you
ModuleNotFoundError: No module named 'mem-edit'
ModuleNotFoundError: No module named 'mem-edit'  Hi, My Python...-edit' How to remove the ModuleNotFoundError: No module named 'mem-edit... to install padas library. You can install mem-edit python with following

Ads