in my script i have the following
if (strlen($new_passwd)>16 || strlen($new_passwd)<4)
{
echo "<div class=\"log\">Passwords must be between<br />4 and 16 chars.";
}
else
{
if ($_SESSION['pass'] != $old_passwd)
echo "<div class=\"log\">Your old password is incorrect<br />please try again.</div>";
if ($new_passwd!=$new_passwd2)
echo "<div class=\"log\">The passwords do not match.<br />passwords not changed.</div>";
}
how do i create a statement that will only execute if non of the above are true, ie. form was filled in correctly?
changing password problem
Moderator: General Moderators
Code: Select all
if (strlen($new_passwd)>16 || strlen($new_passwd)<4)
echo "<div class="log">Passwords must be between<br />4 and 16 chars.";
elseif ($_SESSION['pass'] != $old_passwd)
echo "<div class="log">Your old password is incorrect<br />please try again.</div>";
elseif ($new_passwd!=$new_passwd2)
echo "<div class="log">The passwords do not match.<br />passwords not changed.</div>";
else
{ // none of the above conditions matched
}Mostly i'm doing this with a temp error value.
Code: Select all
unset($error);
if(strlen($_POSTї"new_passwd"]>16 || $_POSTї"new_passwd"])
$error = "Passwords must be between<br /> 4 and 16 chars.<br />";
if($_SESSIONї'pass'] != $_POSTї"old_passwd"])
$error.= "Your old password is incorrect<br />please try again.<br />";
if ($_POSTї"new_passwd"]!=$_POSTї"new_passwd2"]){
$error.= "The passwords do not match.<br />passwords not changed.<br />";
if(isset($error)){
echo "<div class="log">".$error."</div>";
}else{
// update statement. here
}