944,099 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 3455
  • PHP RSS
Jul 11th, 2005
0

Help with password update

Expand Post »
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

PHP Syntax (Toggle Plain Text)
  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
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
alcoholic1 is offline Offline
1 posts
since Jul 2005
Jul 11th, 2005
0

Re: Help with password update

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) {
Reputation Points: 11
Solved Threads: 0
Junior Poster in Training
senexom is offline Offline
54 posts
since Jun 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: PHP, mySQL, Apache all in one
Next Thread in PHP Forum Timeline: Help with Login Box





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC