Hi all,
i have a file called datafile.txt and the content of that file is.............
parag=parag
a=a
123456=123456
admin1=admin1
kapil=123456
in this file i am storing user name and password like in parag=parag first parag is user name and second parag is password.............
now i am writing a php code to change/update the password..................for that i have written code(its not completed) in "updatepass.php" ...............
Code: Select all
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD><TITLE> Update Password </TITLE></HEAD>
<BODY>
<form name="frm" method="post" action="updatepass.php">
<table width="450" align="center" cellpadding="0" cellspacing="0" >
<tr>
<td>Enter Old Password : </td>
<td><input type="text" name="oldpwd" size="30"></td>
</tr>
<tr>
<td>Enter New Password : </td>
<td><input type="text" name="newpwd" size="30"></td>
</tr>
<tr>
<td>Confirm New Password : </td>
<td><input type="text" name="confpwd" size="30"></td>
</tr>
<tr>
<td><input type="submit" name="sub" value="Submit"></td>
</tr>
</table>
</form>
</body>
</html>
Code: Select all
<?php
$oldPwd = $_POST['oldpwd'];
$newPwd= $_POST['newpwd'];
$confPwd= $_POST['confpwd'];
$file="datafile.txt";
$read=parse_ini_file($file);
foreach($read as $key=>$value)
{
if($value==$oldPwd)
{
if($newPwd==$confPwd)
{
$fp = fopen('datafile.ini', "w") or die ("cannot open file");
if(flock($fp, LOCK_EX))
{
$value=$newPwd;
.........................................
..........................................................................
}
}
}
?>after $value=$newPwd; wat i need to do is to store the new password in "datafile.txt "
(to over the old content with a new content and rest file remain same)....so how can i do this............thanx in advance
~pickle | Please use [ code=html ], [ code=php ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: