- Nov 28, 2000
- 2,224
- 0
- 0
Ok heres part of the script, not the full thing:
for($i=0; $i<count($file_array); $i++) {
$found = count(explode($user_str, $file_array[$i]))-1; //$user_str is the Username
if ($found > 0) {
$i++;
$user_fail = 0;
$temp = count(explode($oldpassword, $file_array[$i]))-1; //$oldpassword is the old password
if ($temp > 0) {
$file_array[$i] = str_replace($oldpassword,$newpassword,$file_array[$i]); //$newpassword is the new password
$success = 1;
}
}
$temp = 0;
$found = 0;
}
This is a change password script, but theres a problem with it, it does not search the old password entirely (Ex. "Username:test Old pass: t New pass: testing" would change the password, i want it to search the whole password, so that t does not change the password, unless the full "test" was entered) In other words, if i type only the first character of the old password, it will continue the script and change the password. Not too good! Someone told me i should use "preg_match_all()" function to get it going, i cant seem to understand the function fully, if someone could help me, i would really apprechiate it!
Thanks a lot!
for($i=0; $i<count($file_array); $i++) {
$found = count(explode($user_str, $file_array[$i]))-1; //$user_str is the Username
if ($found > 0) {
$i++;
$user_fail = 0;
$temp = count(explode($oldpassword, $file_array[$i]))-1; //$oldpassword is the old password
if ($temp > 0) {
$file_array[$i] = str_replace($oldpassword,$newpassword,$file_array[$i]); //$newpassword is the new password
$success = 1;
}
}
$temp = 0;
$found = 0;
}
This is a change password script, but theres a problem with it, it does not search the old password entirely (Ex. "Username:test Old pass: t New pass: testing" would change the password, i want it to search the whole password, so that t does not change the password, unless the full "test" was entered) In other words, if i type only the first character of the old password, it will continue the script and change the password. Not too good! Someone told me i should use "preg_match_all()" function to get it going, i cant seem to understand the function fully, if someone could help me, i would really apprechiate it!
Thanks a lot!
