I have a HTML page with a e-mail form (which is connected to a PHP file). I want to put some message for “required fields” in the forms but it’s not working. This is the .php file and no matter what it always shows “You need to fill some fields” even if those 3 fields are filled:
<?php
if ((!$n_empresa_field) || (!$ciudad_field) || (!$email_field))
{
Print "You need to fill some fields";
} else {
$to = "metatron@mymail.com";
$subject = "Cotización...";
$headers = 'From: metatron@mymail.com';
$n_empresa_field = $_POST['n_empresa'];
$direccion_field = $_POST['direccion'];
$colonia_field = $_POST['colonia'];
$cp_field = $_POST['cpostal'];
$dropdown = $_POST['pais'];
$dropdown2 = $_POST['estado'];
$ciudad_field = $_POST['ciudad'];
$telefono_field = $_POST['telefono'];
$n_solicitante = $_POST['n_individuo'];
$email_field = $_POST['email'];
$message = $_POST['message'];
foreach($_POST['check'] as $valor) {
$check_msg.= "$valor
";
}
$body = "Nombre Empresa: $n_empresa_field
Dirección: $direccion_field
Colonia: $colonia_field
Código Postal: $cp_field
País: $dropdown
Estado: $dropdown2
Ciudad: $ciudad_field
Teléfono: $telefono_field
Nombre del que solicita la información: $n_individuo
Email: $email_field
Servicios que necesita:
$check_msg
Comentarios:
$message";
echo 'Thankyou. You can close the window.';
mail($to, $subject, $body, $headers);
}
?>