change password

Ads
 

change password

View Answers

September 24, 2009 at 11:00 AM

Hi Friend,

Try the following code:

1)change.jsp:

<html>
<form action="changePassword.jsp" method="post">
<table>
<tr><td>Current Password</td><td><input type="password" name="current" ></td></tr>
<tr><td>New Password</td><td><input type="password" name="new"></td></tr>
<tr><td>Confirm Password</td><td><input type="password" name="confirm"></td></tr>
<tr><td><input type="submit" value="Change Password"></td></tr>
</table>
</form>
</html>

2)changePassword.jsp

<%@page import="java.sql.*"%>
<%@page import="java.io.*"%>
<%
String currentPassword=request.getParameter("current");
String Newpass=request.getParameter("new");
String conpass=request.getParameter("confirm");
String connectionURL = "jdbc:mysql://localhost:3306/test";;;
Connection con=null;
String pass="";
int id=0;
try{
Class.forName("com.mysql.jdbc.Driver");
con = DriverManager.getConnection(connectionURL, "root", "root");
Statement st=con.createStatement();
ResultSet rs=st.executeQuery("select * from login where password='"+currentPassword+"'");
while(rs.next()){
id=rs.getInt(1);
pass=rs.getString(3);
}
System.out.println(id+ " "+pass);
if(pass.equals(currentPassword)){
Statement st1=con.createStatement();
int i=st1.executeUpdate("update login set password='"+Newpass+"' where id='"+id+"'");
out.println("Password changed successfully");
st1.close();
con.close();
}
else{
out.println("Invalid Current Password");
}
}
catch(Exception e){
out.println(e);
}
%>
Thanks

July 3, 2012 at 4:08 PM

i think problem in looping stmt.... try with if(rs.next())...


October 11, 2012 at 12:14 PM

This post was so very helpful to me, Thank you:)


April 8, 2013 at 10:46 AM

problem in update query

int i=st1.executeUpdate
("update userdetails set password='"+NewPassword+"' where uname='"+uid+"'");
try this

Ads









Related Tutorials/Questions & Answers:
change password
change password  how to change password in the login form.... by giving options to user like this old password, new password.. pls help
password change
password change  Hi , I am using jsf and trying to write a code to change the password of a user . Ihave to retrine userid fromdata base how to do that using session
Advertisements
change kerberos principal password
change kerberos principal password  How to change the password... on the console and enter admin password. then you can use following command to change password: change_password abcd/mydomain.com It will ask for new
How to change password mask field?
How to change password mask field?  I want to use '*' character in password. thanks in advanced............   password masking character in the standard password field can't be changed
ModuleNotFoundError: No module named 'flask-change-password'
ModuleNotFoundError: No module named 'flask-change-password'  Hi...: No module named 'flask-change-password' How to remove the ModuleNotFoundError: No module named 'flask-change-password' error? Thanks   Hi
ModuleNotFoundError: No module named 'flask-change-password'
ModuleNotFoundError: No module named 'flask-change-password'  Hi...: No module named 'flask-change-password' How to remove the ModuleNotFoundError: No module named 'flask-change-password' error? Thanks   Hi
how to change password into one jsp to another jsp
how to change password into one jsp to another jsp  i have two jsps in one jsp i give one password and confirm password, in another jsp i want change...; Here is a jsp code that change the password. 1)change.jsp: <html>
Change Password Code in JSP
Change Password Code in JSP In this example we will see how to change password...(""); ChangePasswordForm.jsp <html> <head> <title>Change password in jsp<...;strong>Change password in JSP form</strong></h2> <body> <
Change root password of MYSQL using Java
Change root password of MYSQL using Java In this tutorial, you will learn how to change the root password of MYSQL database using java code. For every... to change the root password with the known password. For this, we have created
Looking for change password in iphone application sdk using sqlite
Looking for change password in iphone application sdk using sqlite  i am trying to change old password in my iphone application my code is below...) == SQLITE_OK) { NSString *querySQL = [NSString stringWithFormat: @"SELECT password
Password
Password  make a program which ask ask the username and password * in this format. in C language
Password validation
a change password form. In that i have to check the values given in the new... the user and change the password. 1)change.jsp <html> <script>...;td><input type="submit" value="Change Password"></td></tr>
Password validation
Password validation  Hi. I have a change password form. In that i..., New password and conform password from the user and change the password. 1...="Change Password"></td></tr> </table> </form> <
Password validation
Password validation  Hi. I have a change password form. In that i..., New password and conform password from the user and change the password. 1...="Change Password"></td></tr> </table> </form> <
Password validation
Password validation  Hi. I have a change password form. In that i..., New password and conform password from the user and change the password. 1...="Change Password"></td></tr> </table> </form> <
Password validation
Password validation  Hi. I have a change password form. In that i..., New password and conform password from the user and change the password. 1...="Change Password"></td></tr> </table> </form> <
Changing root Password
Changing root Password  how do i change the root password in mysql
forgot password?
forgot password?  forgot password
password check
password check  how to check sighup passowrd and login password
Change Email
Change Email  Hi, I need to change my Rose India register email address for receive email, How did it possible
Reset Password
Reset Password  coding for reset password
retype password
retype password  coding for retype password
code for connecting reset password code to database.
code for connecting reset password code to database.  code for connecting reset password code to database.   Hello Friend, Do you want to change your password and update the password to database
forget password?
forget password?  can anyone help me? how to create a module of forget password?the password can reset by generate random password and send to user's email..i develop the php system using xampp and dreamweaver
forget password?
forget password?  can anyone help me? how to create a module of forget password?the password can reset by generate random password and send to user's email..i develop the php system using xampp and dreamweaver
forget password
forget password  codding for forget password using spring framework
3D PASSWORD
3D PASSWORD  HI i would like to know abt where the 3d password in india used and also few info about the 3d password pls rply some1 as soon as possible
forget password
forget password  can i get coding for forgot password in jsp, need using javamail also cannot.. what should i do?? Thx
foget password
is user login ,second is new user and third is forget password in java using netbeans.so please help me to write the code for forget password button.forget password form have three field that is userid ,security question and answer of those
password - JDBC
password  as memeber of our site, recently he forget his password now he want a new password from us. so overcome with this problem i have to send his password to his any emailid to once again login with this new pasword so
Forget Password
Forget Password  How i get my forget password through mail?   Please visit the following links: http://www.roseindia.net/jsf/richfaces/ http://www.roseindia.net/jsf/richfaces/developing-jsp-files.shtml

Ads