0)
{
if(!checkInput($_POST))
{
$message = '
All fields are required!
';
}
else
{
// do validation
if(preg_match('/^[a-z][^@#$%&*][^0-9]+$/i', trim($_POST['firstName'])))
{
echo "GOOD. Found only alphabet in First Name.
";
}
else
{
echo "BAD. Found something except alphabet in First Name.
";
}
if(preg_match('/^[a-z][^@#$%&*][^0-9]+$/i', trim($_POST['lastName'])))
{
echo "GOOD. Found only alphabet in Last Name.
";
}
else
{
echo "BAD. Found something except alphabet in Last Name.
";
}
if(preg_match('/[a-z0-9]+/i', trim($_POST['password'])))
{
echo "Alphanumeric password is accepted.
";
}
else
{
echo "Can't use these characters for a Password.
";
}
if(preg_match('/^[0-9]{3}[ -][0-9]{3}[ -][0-9]{4}$/', trim($_POST['phoneNumber'])))
{
echo "604-123-1234/123 123 1234 format is valid Phone Number.
";
}
elseif(preg_match('/^(\D*\d){7,10}\D*$/', trim($_POST['phoneNumber'])))
{
echo "7- or 10- degit number is a valid Phone Number.
";
}
elseif(preg_match('/^[0-9]{10}$/', trim($_POST['phoneNumber'])))
{
echo "6041231234 is a valid Phone Number.
";
}
elseif(preg_match('/^([0-9]){3}([0-9]{7})$/', trim($_POST['phoneNumber'])))
{
echo "(604)1231234 is a valid Phone Number.
";
}
else
{
echo "other Phone Number Format.
";
}
if(preg_match('/^[a-z]{3}-[0-9]{2}-[0-9]{4}$/i', trim($_POST['dob'])))
{
echo "VALID. JAN-01-1980 format for Date of Birth is accepted.
";
}
else
{
echo "NOT a valid Date of Birth format.
";
}
/*
if()
{
*/
saveInput($_POST);
/*
$fp = fopen("login.txt", "a+");
fwrite($fp, trim(ucwords(strtolower($_POST['firstName']))) . '|' .
trim(ucwords(strtolower($_POST['lastName']))) . '|' .
trim(ucwords(strtolower($_POST['password']))) . '|' .
trim($_POST['phoneNumber']) . '|' .
trim($_POST['dob']) .
PHP_EOL);
fclose($fp);
*/
/*
} // if()
*/
} // if(!checkInput($_POST))
} // if(count($_POST) > 0)
else
{
$posts = getPosts();
} // if(count($_POST) > 0)
?>
COMP 3015