Hello
Please I need code to make sure that the user enter at-least 6digit character which should be any thing from number to ABC to . to sign… PLEASE I need THIS HELP I have this
if (!preg_match(“/[^a-zA-Z0-9,-]/”.$Fname))
{
die(“Enter your secure Password”);
}
Are they any characters that you are not allowing? If it’s totally open then using:
if(strlen(trim($Fname)) < 6){
// show error message
}
should suffice.
Also, using die() might be a bit harsh than using a simple error message since it forces the user to use their back button instead of letting the script bring them back to the form automatically.
EDIT: I also noticed that you’re checking the $Fname, but the error message relates to a password. If that’s not just a typo make sure you double-check your error messages.
Yes, that method will work, though, setting a relatively large minimum character count for a name seems off – I’d be screwed
If you are only concerned with the length of the text entered, then strlen() should be fine. If there are any specific characters that are required or not allowed, then preg_match() would be the best option.
For not the User can make your of any characters and I am only worry about the length because the User can chose to used any characters… and What where should I put the Error message like this??
if(strlen($Fname) < 6){
// Please Enter your Correct Name
}