Mouradif
Mouradif

Reputation: 2704

Server-side form validation weird error

I have the following PHP code for form processing :

$post = cleanpost($_POST, $db->link);

echo strlen($post['login']).' -- '.strlen($post['pass']); // for debug

if ((strlen($post['login']) < 3) || (strlen($post['pass'] < 7)))
{
    $page = new Page("subscribe");
    $page->assign("msg", "At least 3 characters for the login and 7 characters for the password");
}

The form successfully filters the stated cases (less then 3 chars for the login and less than 7 chars for the password) but sometimes I get filtered when I should pass : I tried to register with "asdf" // "asdfasdf" and I still get the message. As you can see, I have echoed my strlens, they say 4 and 8. I'm totally stuck here

Upvotes: 0

Views: 36

Answers (1)

justtry
justtry

Reputation: 639

if ((strlen($post['login']) < 3) || (strlen($post['pass'] < 7)))

should be:

if ((strlen($post['login']) < 3) || (strlen($post['pass']) < 7))

Upvotes: 1

Related Questions