password confirmation

hi have been following a tuturial on php form validation and here goes

index page
[php]

Form Sample
  1. Name *
  2. Password
  3. Password (confirm)
  4. Favorite Music
    1. Rock
    2. Classical
    3. Reggaeton
  5. How did you hear about us? Choose... A friend Facebook Twitter
  6. Request Type
    1. Question
    2. Comment
    3. Suggestion
  7. Comment
send [/php]

process page

[php]<?php

$myname = $_REQUEST[‘myname’];
$mypassword = $_REQUEST[‘mypassword’];
$mypasswordconf = $_REQUEST[‘mypasswordconf’];

if ($myname === ‘’) :
echo “

Sorry, your name is a required field
”;
endif; // input field empty

if (strlen($mypassword) <=6):
echo “

Sorry, the password must be at least six characters
”;
endif; //password not long enough

if ($mypassword !== $mypasswordconf) :
echo “

Sorry, passwords must match
”;
endif; //passwords don’t match

?>[/php]

when i check that they match the passwords i mean

it returns the following error although i have checked that the passwords are identical

Sorry, the password must be at least six characters

this error i believe means that the password fiels differ

some help please

and thankyou

Please use the php code block function when adding code :slight_smile:
(I fixed it for you this time)

The error seem to suggest you are submitting a password with 6 or less characters. As the condition is written the error message should be “Sorry, the password must be at over six characters”


phpcodeblock.png

This following code means that the passwords needs to be 7 characters…
[php]
if (strlen($mypassword) <=6):
echo “

Sorry, the password must be at least six characters
”;
endif; //password not long enough
[/php]
The if statement reads like this…
"If the string length of my password is less than or equal to 6, then echo “Sorry, the password must be at least six characters”.

If you want the minimum length to be 6 then you need to remove the “=” from “<=” or change the value to 5 instead of 6.

so it should read like this…
[php]
if (strlen($mypassword) < 6):
echo “

Sorry, the password must be at least six characters
”;
endif; //password not long enough
[/php]
"If the string length of my password is less than or equal to 6, then echo “Sorry, the password must be at least six characters”.
Sponsor our Newsletter | Privacy Policy | Terms of Service