use md5()
it will save you headaches 🙂
for inserting for the first time:
// $password should be PLAIN TEXT starting out
$new_password = md5($password);
// this section should insert the $new_password INTO the file.
....
....
// okay, now we have them logging in again.
// they send $password as PLAIN_TEXT (ie. just type it in
// from a form and hit submit)
$new_password = md5($password);
$f = fopen($filename, "r");
$line = fgets($f, 1000);
if (ereg("password (.*)", $line, $reOut)) {
$stored_password = $reOut[1];
// if you need to get rid of quotes
// use this next line, otherwise yank it.
// (wasn't sure if you wrote to file with quotes)
$stored_password = str_replace("\"","",$stored_password);
if ( $stored_password == $new_password)
{
echo "passed check.";
}
else
{
echo "failed check.";
}
***NOTE: this is assuming your ereg of pulling the information from the file is WORKING PROPERLY.
md5() is so easy. you md5() the user's password at the very beginning, and then everytime after that you just md5() the users input (for password) and compare the value in the file.
cheers,
kyle