Im making a web form using the following code that is down below:
<?php
$nombre = $_POST['nombre'];
$mail = $_POST['correo'];
$empresa = $_POST['mensaje'];
$telefono = $_POST['telefono'];
$header = 'From: ' . $mail . " \r\n";
$header .= "X-Mailer: PHP/" . phpversion() . " \r\n";
$header .= "Mime-Version: 1.0 \r\n";
$header .= "Content-Type: text/plain";
$mensaje = "Este mensaje fue enviado por: " . $nombre . ",\r\n";
$mensaje .= "Su e-mail es: " . $mail . ",\r\n";
$mensaje .= "Su teléfono (y WhatsApp) es: " . $_POST['telefono'] . ",\r\n";
$mensaje .= "Mensaje: " . $_POST['mensaje'] . ". \r\n";
$mensaje .= "Consulta realizada el " . date('d/m/Y', time());
$para = 'there goes the mail, ofc';
$asunto = '¡Nuevo formulario de contacto!';
mail($para, $asunto, utf8_decode($mensaje), $header);
header("Location: contacto.html");
echo '<script language="javascript">alert("Su consulta ha sido enviada correctamente");</script>';
?>
The problem is on the last lines of codes, where Im actually trying to send a message to the sender that the mail has been sent succesfully.
I must also say, that I tried to put the echo before the header and it still not working.