change password

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









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
Change Password - JSP-Servlet
Change Password  Hi all, Please kindly help me with jsp code and explanations to enable me write a change password program. This program will connect to mssql database 2000. Thanks
change password - JSP-Servlet
change password  hi, my problem is as follows: i am creating... for a user. this web page consists of changing the password for the existing user. it look like this: current password new password confirm new password SUBMIT
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
change password servlets - JSP-Interview Questions
change password servlets  hi all, i need the codes to create a change... a link for change the password page in that page there should be a three text box... you.  Hi friend, i am sending a code to change password by servlet
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...;head> <title>Change password in jsp</title> <meta http-equiv...;/head> <h2 align="center"><strong>Change password in JSP
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... we are going to change the root password with the known password. For this, we
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
array password - Java Beginners
array password  i had create a GUI of encryption program that used the array password. my question is can we do the password change program? i mean we change the older password with the new password
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
MySQL Creating account and changing password
or  you want to change the password then make new user .This lesson you learn how... change the  password to same random to be string . the better way... MySQL Creating account and changing password   
forgot password?
forgot password?  forgot password
password check
password check  how to check sighup passowrd and login password
Password History - JSP-Servlet
Password History  I am using servlets and in my application i want to maintain password history.It means on password change My application should check previous 5 password so that new password can't be same to 5 old password
Reset Password
Reset Password  coding for reset password
retype password
retype password  coding for retype password
color change
color change  how to change the color in circle using scrollbar
Change Email
Change Email  Hi, I need to change my Rose India register email address for receive email, How did it possible
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
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
Forgot password
Forgot password  hi i want to develop a code for when user clicks on forgot password then the next page should be enter his mobile no then the password must be sent to his mobile no...! Thanks in advance Nag Raj
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
password - Security
password  How can i do password encript and decript in java  Hi friend, Code to encript and decript password in java import... password= "Hello"; System.out.println("input " + password
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
secure password
secure password   Respected Sir We need to write a function which accepts a given password and returns ââ?¬Å?ACCEPTEDââ?¬Â? or ââ?¬Å?REJECTEDââ?¬Â? based on the following rules: Passwords must consist of a mixture
secure password
secure password   Respected Sir We need to write a function which accepts a given password and returns ââ?¬Å?ACCEPTEDââ?¬Â? or ââ?¬Å?REJECTEDââ?¬Â? based on the following rules: Passwords must consist of a mixture
Username password
with the validation, so that if the username and password match it will continue... that checks whether the username and password is valid or not. If the user...("Password:"); text2 = new JPasswordField(15); SUBMIT=new JButton("SUBMIT
java password function
java password function  secret password function
How to change background, change background
How to change background       This example will teach you to change background of any object... a picture to change background.ADS_TO_REPLACE_1 Selection: Make selection
change file permission in php
change file permission in php  How to change file permission in PHP
change appearance of alert box
change appearance of alert box  how to change the appearance of an alert() box
Change orientation of UIViewController
Change orientation of UIViewController  Is it possible to change the UIViewController orientation dynamically
change value of mutable string
change value of mutable string  How to change value of mutable string
change content of cell javascript
change content of cell javascript  change content of cell javascript

Ads