Help with password update

Reply

Join Date: Jul 2005
Posts: 1
Reputation: alcoholic1 is an unknown quantity at this point 
Solved Threads: 0
alcoholic1 alcoholic1 is offline Offline
Newbie Poster

Help with password update

 
0
  #1
Jul 11th, 2005
Hey all ive been trying to get the code bellow to work which should make an update password fourm but im not having much luck if any one can tell me why it's not working i will jump up and down around the room looking stupid lol

  1.  
  2. <?php
  3. require_once('Connections/koc.php');
  4. require_once('includes/functions.inc.php');
  5. ?>
  6. <html>
  7. <head>
  8. <title>Untitled Document</title>
  9. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  10. </head>
  11.  
  12. <body>
  13. <?php
  14. if (isset($_POST['submit'])) {
  15. $invalid = false;
  16. foreach ($_POST as $key => $value) {
  17. if (empty($value)) {
  18. $invalid = true;
  19. }
  20. }
  21.  
  22. if ($invalid) {
  23. echo "<p>You must fill in all fields!</p>\n";
  24. } else {
  25. if ($_POST['new_pw1_urs'] = $_POST['new_pw2_urs']) {
  26. echo "<p>New Passwords do not match!</p>\n";
  27. } else {
  28. $query = mysql_query("SELECT * FROM login WHERE username_urs = '$_POST[username_urs]' AND password_urs = '" .($_POST['old_pw_urs']) . "'");
  29. if (mysql_num_rows($query) = 1) {
  30. echo "<p>Invalid username/password combination!</p>\n";
  31. } else {
  32. if (mysql_query("UPDATE login SET password_urs = '" .($_POST['new_pw1_urs']) . "' WHERE username_urs = '$_POST[username_urs]'")) {
  33. echo "<p>Password updated!</p>\n";
  34. } else {
  35. echo "<p>Couldn't update password!</p>\n";
  36. }
  37. }
  38. }
  39. }
  40. }
  41. ?>
  42.  
  43. <form name='update_pw' action='' method='post'>
  44. Username: <input type='text' name='username_urs' /><br />
  45. Password: <input type='password' name='old_pw_urs' /><br />
  46. New PW: <input type='password' name='new_pw1_urs' /><br />
  47. Confirm New PW: <input type='password' name='new_pw2_urs' /><br />
  48. <input type='submit' name='submit' value='Change it!' />
  49. </form>
  50.  
  51. </body>
  52. </html>

the error code that keeps been displayed is
Parse error: parse error in H:\server\Apache2\htdocs\koc\TMP25ae9jga7r.php on line 28

the database is called test and the table used is called login and the fields for the username and password are username_urs and password_urs
Last edited by alcoholic1; Jul 11th, 2005 at 3:35 am. Reason: adding in more information
Reply With Quote Quick reply to this message  
Join Date: Jun 2005
Posts: 54
Reputation: senexom is an unknown quantity at this point 
Solved Threads: 0
senexom's Avatar
senexom senexom is offline Offline
Junior Poster in Training

Re: Help with password update

 
0
  #2
Jul 11th, 2005
try changing your line (28) from this...
if (mysql_num_rows($query) = 1) {

to this...
if (mysql_num_rows($query) > 0) {
or if you really need to make sure there is only one record returned ...
if (mysql_num_rows($query) == 1) {
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the PHP Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC