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:
AT&T devCentral & BlackBerry(r) Webcast Series: BlackBerry and GPS -Build Location Awareness into your BlackBerry Applications, July 10th-1:00PM EST. Register Today!
  #1  
Old September 28th, 2002, 12:24 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
Password

hello,

Very simple one.What I'm trying to do is...I'm writing a script to change the user password.

How???

1.The user enters his old password.

2.Enter the new password and re-enter it.

3.IF the old password is same as in the table and the new password entered twice is same, the password is updated.

Fine, I've written the script and it is working fine.

The problem is, i also want to display the error messages like:

1) If the old password entered is wrong or the new password which is entered twice are not same, there should be a message displayed.

I'm able to display the message when the password which is entered twice is not same, it displays me the message.

I ALSO WANT TO DISPLAY IF MY OLD PASSWORD IS WRONG.

How can i check for that.
ps:my old password is in encrypted form.ie,i used md5.
This is the script for your reference, absolutely no errors.
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 28th, 2002, 02:37 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: Password

Just before you update query, run another query to check the old password:
php Code:
Original - php Code
  1.  
  2. $sql="SELECT * FROM TBL_USER WHERE USER_NAME ='admin' AND USER_PASSWORD= '".md5($oldpassword)."'";
  3.  
  4. $result=ibase_query($connection,$sql);
  5.  
  6. if(ibase_num_fields($result) == 0) {
  7.   echo "Old password is incorrect!";
  8.   exit;
  9. }

Reply With Quote
  #3  
Old September 28th, 2002, 05:14 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
RE: Password

hello Matt,
Thanks for your tip.BUt, it does'nt display me any errors now.I entered the old password wrong,the new password also wrong.Now, when i submit, i just dont get any error messages.could you pls tell me why???

Thanks once again.

Here is the code.

Code:
<?

include "../dbconnection.ini";

	if (isset($submit) && isset($oldpassword))
    {
    if ($newpassword <> $newpassword2)
      {
  	echo "New passwords do not match. Please re-enter passwords!";
	exit;
      }
	$sql="SELECT * FROM TBL_USER WHERE USER_NAME ='admin' AND USER_PASSWORD= '".md5($oldpassword)."'";
    $result=ibase_query($connection,$sql);

    if(ibase_num_fields($result) == 0) 
	    {
    echo "Old password is incorrect!";
    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="image" src="../images/sign_save.gif" value="submit" name="submit">";
   echo"</form></body></html>";
   }
?>

Reply With Quote
  #4  
Old September 28th, 2002, 05:50 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: Password

Hmm..that's strange. Something should be printed...try putting:

error_reporting (E_ALL);

at the top of your script. Maybe some errors are being suppressed?


Reply With Quote
  #5  
Old September 28th, 2002, 06:01 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
RE: Password

yep, that sounds really weird.I dont get any errors displayed still.Is my code is in order??

Thanks any way Matt.

Reply With Quote
Reply

Viewing: Codewalkers ForumsPHP RelatedPHP Coding > 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 4 hosted by Hostway