Currently I'm having troubles getting my Password validation to work properly for my profile page. The user is supposed to be able to change their password after typing in their password. It's currently giving me the error "Invalid Password" no matter what I type. Here is the code. Any help appreciated. (I'm not getting any sql errors)
$update = "UPDATE `users` SET `fname`='$fnamenew', `lname`='$lnamenew', `email`='$emailnew' WHERE `username`='$username'"; mysql_query($update);
//////////// Email Validation //////////// function validEmail($email) { $isValid = true; $atIndex = strrpos($email, "@"); if (is_bool($atIndex) && !$atIndex) { $isValid = false; } else { $domain = substr($email, $atIndex+1); $local = substr($email, 0, $atIndex); $localLen = strlen($local); $domainLen = strlen($domain); if ($localLen < 1 || $localLen > 64) { // local part length exceeded $isValid = false; } else if ($domainLen < 1 || $domainLen > 255) { // domain part length exceeded $isValid = false; } else if ($local[0] == '.' || $local[$localLen-1] == '.') { // local part starts or ends with '.' $isValid = false; } else if (preg_match('/\\.\\./', $local)) { // local part has two consecutive dots $isValid = false; } else if (!preg_match('/^[A-Za-z0-9\\-\\.]+$/', $domain)) { // character not valid in domain part $isValid = false; } else if (preg_match('/\\.\\./', $domain)) { // domain part has two consecutive dots $isValid = false; } else if (!preg_match('/^(\\\\.|[A-Za-z0-9!#%&`_=\\/$\'*+?^{}|~.-])+$/', str_replace("\\\\","",$local))) { // character not valid in local part unless // local part is quoted if (!preg_match('/^"(\\\\"|[^"])+"$/', str_replace("\\\\","",$local))) { $isValid = false; } } if ($isValid && !(checkdnsrr($domain,"MX") || checkdnsrr($domain,"A"))) { // domain not found in DNS $isValid = false; } } return $isValid; } //////////// End Email Validation /////////
if (isset($passwordconf) && !empty($passwordconf)){
if ($passwordnew==$passwordconf){
$passupdate = "UPDATE `users` SET `password`='$passwordnew' WHERE `username`='$username'"; mysql_query($passupdate);
$passsuccess = "Success!";
} else{ $error = "Your passwords do not match!"; }
} else{ $error = "Please type in your Confirmed Password!"; }
} else{ $error = "Please type in your New Password!"; }
} else{ $error = "Invalid Password"; }
} else{ $error = "Please type in your Password!"; }
}
}
?>
<html> <head> <title>Profile</title>
<script type="text/javascript" language="javascript"> function inputLimiter(e,allow) { var AllowableCharacters = '';
if (allow == 'UserNameChar'){AllowableCharacters='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';} if (allow == 'UsernameChar'){AllowableCharacters='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890';}
I like your code but was not able to spot any thing myself. Not sure what you are using to do your code with but I found an editor called CodeLobster that allows you to step through the code line by line which I find helpfull at time.