I'm breaking my head here. First time toying with PHP. I have a form with several fields that are required. If a user tries to send an empty field, it needs to be caught. If I type a space, the form goes through. Any help will be truly appreciated.
This is the code for one field
if( isset($_POST['first_name']) and !empty($_POST['first_name']) and trim($_POST['first_name']) != '' ) $first_name = filter_var($_POST['first_name'], FILTER_SANITIZE_MAGIC_QUOTES);
else {
$redirect = SITE_URL . substr($section, -4) . '/' . substr($section, 0, -4) . '/' . $referPage . 'first_name=' . $first_name . '&last_name=' . $last_name . '&email=' . $email . '&phone' . $phone . '&country=' . $country . '#mailingList' and header ( "Location: $redirect" );
}