I have a enrollment form where users have to input there address. I am using PHP for validation and currently I check to make sure the field is not empty. Here is my code:
if (empty($_POST['address'])) {
$msg = 'You must enter an address' ;
} else {
$address = mysqli_real_escape_string($dbc, strip_tags(trim($_POST['address']))) ;
}
Now the problem is that is the user enters in a "blank" space by pressing the spacebar the filed passes validation. What I need is a way to make sure the user actually typed in a city and not just a blank space or a couple of blank spaces.
trim
variable before you validate it