I would take an guess that the value $vin
is an array, null or undefined and thus the function call strlen($vin)
is returning zero every time.
see documentation for strlen here
Change your code to the following to debug the values:
if(strlen($vin) != 17) {
echo "VIN is not 17 digits";
echo "VIN is " . strlen($vin) . " digits";
echo "VIN value is: " . $vin;
} else {
mail($admin_email, "Auto Quote Request", $email_body);
echo "Thank you for contacting us!";
}
edit possible solution number 2:
strlen() returns the number of bytes rather than the number of characters in a string.
As suggested by a comment by chernyshevsky in the strlen docs do the following:
pass the string through utf8_decode() first:
if(strlen(utf8_decode($vin)) != 17) {
echo "VIN is not 17 digits";
echo "VIN is " . strlen(utf8_decode($vin)) . " digits";
echo "VIN value is: " . $vin;
} else {
mail($admin_email, "Auto Quote Request", $email_body);
echo "Thank you for contacting us!";
}
utf8_decode() converts characters that are not in ISO-8859-1 to '?', which, for the purpose of counting the number of characters will work.