Howdy, I just have a small problem with my forms. I have 2 passwords fields for people to verify their password. I put this code near the top of the page that is processed by the 'submit' button:

if ($password != $vpassword)
{
print "<p><font size=\"3\" face=\"Verdana, Arial\" color=\"#FF0000\"><b>Passwords must match!</b></font></p>";
exit;
}

But it displays all the time, even if the passwords do or don't match. Any ideas?

    The error doesn't seem to be here; is there anything done to $password and $vpassword before this part is reached? Could the error be back on the form itself?

      I believe you should use == to have a correct comparison, using only one means nothing.

      try:

      if($password !== $vpassword)

        Doesn't seem to help. If I do it all in one text file it works, like:

        $password = 'hello';
        $vpassword = 'hello';

        if($password !== $vpassword)
        {
        print "<p><b>Passwords Must Match!</b></p>";
        exit;
        }

        So I guess the form has something to do with it. Although, I also have the code:
        if (!trim($password))
        {
        print "<p>The password cannot be left blank</p>";
        exit;

        And that seems to work fine, so I guess I'll just look into it some more.
        }

          this is not true, the !== operator tests for unequal value and type, the != operator test for value only. != should work in this case.

            fixed it by putting the code lower down in the page.... not sure why this makes a difference, but results are what count i guess

              Write a Reply...