473,473 Members | 1,974 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

how to change or update password

2 New Member
hi there,
im having problem to provide "change password" feature. ive tried several coding but nothing can solve it.

does anyone had experience regarding this problem?
Apr 23 '10 #1
2 2424
Atli
5,058 Recognized Expert Expert
Hey.

What have you tried so far?
Why/how does it not work?
Did you get any errors? Any unexpected behavior?
Can we see the code?

As far as theory goes (which is all I can give you, without any useful info regarding your situation), this should be as simple as:
  1. Have the user submit the old password and the new password. And optionally a password "check" field, to make sure he entered it correctly.
  2. Make sure the old passwords match.
  3. If a "check" field was passed, make sure it matches the new password.
  4. Update the database, using the new password.
Apr 23 '10 #2
aries283
2 New Member
@Atli
the password didnt update.even if ive used the update function.
here's the code.
Expand|Select|Wrap|Line Numbers
  1. <?php require_once('Connections/annajmi.php'); ?>
  2. <?php
  3. $colname_Recordset1 = "-1";
  4. if (isset($_GET['pel_nsb'])) {
  5.   $colname_Recordset1 = (get_magic_quotes_gpc()) ? $_GET['pel_nsb'] : addslashes($_GET['pel_nsb']);
  6. }
  7. mysql_select_db($database_annajmi, $annajmi);
  8. $query_Recordset1 = sprintf("SELECT * FROM pelajar WHERE pel_nsb = '%s'", $colname_Recordset1);
  9. $Recordset1 = mysql_query($query_Recordset1, $annajmi) or die(mysql_error());
  10. $row_Recordset1 = mysql_fetch_assoc($Recordset1);
  11. $totalRows_Recordset1 = mysql_num_rows($Recordset1);
  12.  
  13.  
  14. if (isset($_POST['hantar'])) { 
  15. // Handle the form.
  16.  
  17.  
  18.  
  19. // Create a function for escaping the data. 
  20. function escape_data ($data) { 
  21. global $dbc; // Need the connection. 
  22. if (ini_get('magic_quotes_gpc')) { 
  23. $data = stripslashes($data); 
  24. return mysql_real_escape_string($data, $dbc); 
  25. // End of function.
  26.  
  27. $message = NULL; // Create an empty new variable.
  28.  
  29.  
  30. // Check for an existing password. 
  31. if (empty($_POST['katalaluan'])) { 
  32. $pa = FALSE; 
  33. $message .= '<p>You forgot to enter your existing password!</p>'; 
  34. } else { 
  35. $pa = escape_data($_POST['katalaluan']); 
  36. }
  37.  
  38. // Check for a password and match against the confirmed password. 
  39. if (empty($_POST['katalaluanbaru'])) { 
  40. $npa = FALSE; 
  41. $message .= '<p>You forgot to enter your new password!</p>'; 
  42. } else { 
  43. if ($_POST['katalaluanbaru'] == $_POST['pastikatalaluan']) { 
  44. $npa = escape_data($_POST['katalaluanbaru']); 
  45. } else { 
  46. $npa = FALSE; 
  47. $message .= '<p>Your new password did not match the confirmed new password!</p>'; 
  48. }
  49.  
  50. if ($lo && $pa && $npa) { // If everything's OK.
  51.  
  52. $query = "SELECT * FROM pelajar WHERE (katanama=='$lo' AND katalaluan==katalaluan('$pa') )"; 
  53. $result = @mysql_query ($query); 
  54. $num = mysql_num_rows ($result); 
  55. if ($num == '1') { 
  56. $row = mysql_fetch_array($result);
  57.  
  58. // Make the query. 
  59. $query = "UPDATE pelajar SET katalaluan=katalaluan('$npa') WHERE pel_nsb=$pel_nsb"; 
  60. $result = @mysql_query ($query); // Run the query. 
  61. if (mysql_num_rows() == 1) { // If it ran OK.
  62.  
  63. // Send an email, if desired. 
  64. echo '<p><b>Your password has been changed.</b></p>';
  65.  
  66. exit(); // Quit the script.
  67.  
  68. } else { // If it did not run OK. 
  69. $message = '<p>Your password could not be changed due to a system error. We apologize for any inconvenience.</p><p>' . mysql_error() . '</p>';
  70. } else { 
  71. $message = '<p>Your loginName and password do not match our records.</p>'; 
  72. mysql_close(); // Close the database connection.
  73.  
  74. } else { 
  75. $message .= '<p>Please try again.</p>'; 
  76. }
  77.  
  78. } // End of the main Submit conditional.
  79.  
  80. // Print the error message if there is one. 
  81. if (isset($message)) { 
  82. echo '<font color="red">', $message, '</font>'; 
  83. ?>
  84.  
  85.  
  86. <p>&nbsp;</p>
  87. <p>&nbsp;</p>
  88. <form name="form1" method="post" action="">
  89.   <p>&nbsp;</p>
  90.   <fieldset>
  91.   <legend>Enter your information in the form below:</legend>
  92.   <p><b>Current password:</b>
  93.       <input type="katalaluan" name="katalaluan" size="20" maxlength="20" />
  94.   </p>
  95.   <p><b>New password:</b>
  96.       <input type="katalaluanbaru" name="katalaluanbaru" size="20" maxlength="20" />
  97.   </p>
  98.   <p><b>Confirm New password:</b>
  99.       <input type="pastikatalaluan" name="pastikatalaluan" size="20" maxlength="20" />
  100.   </p>
  101.   </fieldset>
  102.   <div align="center">
  103.     <input type="submit" name="submit" value="change My password" />
  104.   </div>
  105.   <?php
  106. mysql_free_result($Recordset1);
  107. ?>
  108.  
Apr 23 '10 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Fredrik/Sweden | last post by:
Hi folks ! got this problem... i have a table 'Accounts' in my database, which contains a bunch of users. From the main menu i choose "edit user" and all users in the db are presented in a table....
2
by: Danny | last post by:
Hello I am looking for an asp change password solution. I know there are very efficient ways of doing it and perhaps you have some samples or ideas. Basically I would like the user to be able...
12
by: Florian | last post by:
I've been stumbling over this, what I consider strange, behaviour. I installed mySQL on a Win2k machine and tried to change the root password, which didn't seem to work. I changed it this way: ...
13
by: J.P | last post by:
Hi! Anyone knows if it's possible to do an update if, and only if my condition is TRUE. Example: In MYTABLE I have three columns, like this: ID(INT), PUBLISH(ENUM(Y,N)),...
1
by: roshina | last post by:
Hi Iam facing a problem in my project, developing a web site for online shopping in ASP on windows XP using IIS server. All the validations are ok but the new password is not upadated in the data...
3
by: dhaneshrs | last post by:
I have a gridview i managed to update using the edit option in the smartmenu. The problem comes when i delete a value or make a value read only. Say i have a table Employee with the following...
5
by: =?Utf-8?B?UlBhcmtlcg==?= | last post by:
I used the wizard to generate a typed dataset for my table and let it create my SPROCs. It created everything, and the GetData() method and the custom GetByUserName query works great, but when I...
2
by: yasinirshad | last post by:
Hi, Please see my below code to change password. Here i need to check for old password from database and need to update new password. But when i try to submit by giving wrong old password ,its...
7
by: rekhasc | last post by:
plz help me to write the code to change the current password and to update the new password: i have written the code but its giving error,my code is Private Function pass() As Boolean Dim cn...
4
by: raj200809 | last post by:
Hi, I m trying update password in database using asp.net with c#. I have three text box in my aspx page Old password New password confirm password i m using following code but its not...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.