解決策を探してみましたが、決定的なものは見つかりませんでした。
基本的に、ユーザー名とパスワードをリストした txt ファイルがあります。特定のユーザーのパスワードを変更できるようにしたい。
users.txt ファイルの内容:
user1,pass1
user2,pass2
user3,pass3
次のphpコードを試しました:
// $username = look for this user (no help required)
// $userpwd = new password to be set
$myFile = "./users.txt";
$fh = fopen($myFile,'r+');
while(!feof($fh)) {
$users = explode(',',fgets($fh));
if ($users[0] == $username) {
$users[1]=$userpwd;
fwrite($fh,"$users[0],$users[1]");
}
}
fclose($fh);