Page 1 of 1

changing password problem

Posted: Tue May 13, 2003 8:42 am
by irealms
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?

Posted: Tue May 13, 2003 8:51 am
by volka

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
	
}
you might use else if instead of elseif as well

Posted: Tue May 13, 2003 8:55 am
by []InTeR[]
Mostly i'm doing this with a temp error value.

Code: Select all

unset($error);
if(strlen($_POST&#1111;"new_passwd"]>16 || $_POST&#1111;"new_passwd"])
  $error = "Passwords must be between<br /> 4 and 16 chars.<br />";

if($_SESSION&#1111;'pass'] != $_POST&#1111;"old_passwd"])
  $error.= "Your old password is incorrect<br />please try again.<br />";

if ($_POST&#1111;"new_passwd"]!=$_POST&#1111;"new_passwd2"])&#123;
  $error.= "The passwords do not match.<br />passwords not changed.<br />";

if(isset($error))&#123;
  echo "<div class="log">".$error."</div>";
&#125;else&#123;
  // update statement. here  
&#125;

Posted: Tue May 13, 2003 8:57 am
by m3mn0n

thanks

Posted: Tue May 13, 2003 8:59 am
by irealms
thanks for the help, it's working now

only problem i have now is that it only lets you change the password once unless you log out and in again