SunQuest
           PHP Coding
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsPHP RelatedPHP Coding

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
You eat, breathe and sleep innovation. Build your mobile intelligence with BlackBerry® experts this July. Register Today!
  #1  
Old September 26th, 2002, 11:59 AM
Anonymous Anonymous is offline
Registered User
Codewalkers God 35th Plane (22000 - 22499 posts)
 
Join Date: Apr 2007
Posts: 22,309 Anonymous User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 24
Changing password

hello,

I'm trying to change the password of the user(admin).I want the user to type his old password and a new password twice.If the old password is the same as that of in the table and the new password which is typed twice is same, the table is updated with the new password else it has to display the error message.The password is stored in the encrypted form, i.e using Md5.Could somebody pls tell me where the error is.
Many thanks

Code:
<?

include "../dbconnection.ini";

if (isset($submit) && isset($oldpassword))
    {
if ($newpassword <> $newpassword2)
        {
echo "New passwords do not match. Please re-enter passwords!";
        exit;
        }
        else
        	 {
$sql="update TBL_USER set USER_PASSWORD= '".md5($newpassword)."' where USER_NAME ='admin' AND USER_PASSWORD= '".md5($oldpassword)."'";
      $result=ibase_query($connection,$sql);
      if (!$result)
      {
echo "Error executing the update statement. <br/>Interbase Reported:".ibase_errmsg()." <br/>".
      "SQL=$sql<br />n";
      }
      else
      	{
      echo "Password successfully changed!";
      	}
      		}
   }
	else
         {
   echo"<link rel="stylesheet" type="text/css" href="../formate.css">";
   echo"<form action="$PHP_SELF" method="POST">n";
   echo"<h4>Change administrator password</h4>";
   echo"<table border="0" width="364" height="1">
   <tr>
   <td width="185" height="17">Old password</font></td>
   <td width="163" height="17">
   <p><input type="password" name="oldpassword"></p></td>
   </tr>
   <tr>
   <td width="185" height="17">New password</font></td>
   <td width="163" height="17">
   <p><input type="password" name="newpassword"></p>
   </td>
   </tr>
   <tr>
   <td width="185" height="1">Repeat new password</font></td>
   <td width="163" height="1"><input type="password" name="newpassword2"></td>
   </tr>
   </table>
   ";
  echo"<input type="submit" value="submit" name="submit">";
  echo"</form></body></html>";
  	   }
?>


Reply With Quote
  #2  
Old September 26th, 2002, 12:17 PM
Anonymous Anonymous is offline
Registered User
Codewalkers God 35th Plane (22000 - 22499 posts)
 
Join Date: Apr 2007
Posts: 22,309 Anonymous User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 24
I fixed it


Reply With Quote
  #3  
Old September 26th, 2002, 12:22 PM
Matt Matt is offline
Moderator
Codewalkers Specialist (4000 - 4499 posts)
 
Join Date: Apr 2007
Location: Florida
Posts: 4,158 Matt User rank is Private First Class (20 - 50 Reputation Level)Matt User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 4 h 10 m 20 sec
Reputation Power: 6
RE: Changing password

Well, if you are getting an error message, please post that....

One logic error I see though is this:

php Code:
Original - php Code
  1. $sql="update TBL_USER set USER_PASSWORD= '".md5($newpassword)."' where USER_NAME ='admin' AND USER_PASSWORD= '".md5($oldpassword)."'";
  2.       $result=ibase_query($connection,$sql);
  3.       if (!$result)
  4.       {


As long as it is a valid query (which it appears to be), it will always return true. So even if the old password does not match the one in the database, it will report that the password was changed even though it hasn't been. The better way would be to do a select query for the admin name and old password, if you get a any rows back, then update with the new password.

Reply With Quote
Reply

Viewing: Codewalkers ForumsPHP RelatedPHP Coding > Changing password


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway