I have a $name variable containing a string, and when I test it, I never get the \"Name should be between 2 and 40 characters\" error even when it\'s less than
$name
How can the length be less than 2 and greater than 40? You want || ("or"), not && ("and").
||
&&
if (strlen($name) < 2 || strlen($name) > 40) { // -------------------^^