Hi,
I'm developing my registration script and have one problem on my checks. All checks work ok except the code doesn't check the password length correctly, It allows registration if the pw is less than 6 chars when it should only allow registration if the pws are greater than 6 but less than 16.
The code reads: if ((strlen($password) < 6) || (strlen($password) > 16)) // This should work to me, if strlen less than 6 or strlen greater than 16 but I've obviuosly made a mistake.
Please find the code below:
<?php
if ($email && $username && $password && $password2) // AAA - If fields filled out on form. OK
{
if ($password == $password2) // BBB - If entered passwords match on form. OK
{
if (strstr($email, "@")&& strstr($email, ".")) // CCC - If email has @ sign and a dot on form. OK
{
if ((strlen($password) < 6) || (strlen($password) > 16)) // DDD - DOES NOT WORK PROPERLY - Less than 6 granted.
{
$sqlCommand = "INSERT INTO clients (email, username, password)
VALUES('$email','$username','$password')";
$query = mysql_query($sqlCommand) or die (mysql_error());
$clientid = mysql_insert_id();
echo "<b>You have been registered. Your clientid is: </b>" . $clientid;
mysql_close();
}
else
echo "Your password must be between 6 and 16 characters, please go back and try again."; // DDD
}
else
echo "No @ sign or dot in email address."; // CCC
}
else
echo "Passwords did not match"; // BBB
}
else
echo "Please fill out the registration form correctly. None or only part of the details were supplied."; // AAA
?>
Any help would be really useful because for the life of me I cannot understand why this code will not work correctly.
Many thanks