Another quick question.

I have a form to enter user and password. The validation processes are performed correctly in the sense of checking the user and password combination correctly.

I now have a problem with leading and trailing spaces in the password field.

before i perform the password check in the mysql database, i run the trim($user) and trim($password) functions, but they don't appear to be working. is there a special way i need to do this since it's a password field in the form?

so if user=joe and password=smith

you can enter user=joe and password= smith

and it still works...

thanks in advance

    Without seeing your actual code, one likely possibility is that you're forgetting that PHP parameters by default are passed by value, so the statement

    trim($password);

    only trims the temporary copy that is the function's parameter. You need to say it like this:

    $password = trim($password);

      i'm using

      //trim all the fields
      $user=trim($user);
      $password=trim($password);

      so i don't think that is the problem

        • [deleted]

        I take it you are not doing

        if ($user='joe' and $password='smith')

        but

        if ($user=='joe' and $password=='smith')

        and as allways, print, print and print some more.

        echo 'Data from form:--'.$form_password."--\n";
        $form_password=trim($form_password);
        echo 'Trimmed data from form:--'.$form_password."--\n";
        echo 'Data ro compare with:--'.$password."--\n";

        and so on.
        The minus signs let you see spaces etc more easily.

          Write a Reply...