Simple PHP question, i know you guys can help!

WarDemon666

Platinum Member
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!
 

WarDemon666

Platinum Member
Nov 28, 2000
2,224
0
0
Up

Really need some help guys, what would i do for it to search the whole old password instead of only the first letter?

Thanks!
 

WarDemon666

Platinum Member
Nov 28, 2000
2,224
0
0
Anyone??

Would you need more information to be able to help me? I really wanna fix this :(

thanks in advance
 

WarDemon666

Platinum Member
Nov 28, 2000
2,224
0
0
Yes i have, i dont know how to insert that in my code so it actually searches the whole phrase instead of just the first character, someone must know how to do this!

Thanks