Fix Notice: Undefined variable and Warning: Can not modify header information - headers already sent

0

My code .php is:

<?php
$Nombre = $_POST['Nombre'];
$Apellidos = $_POST['Apellidos'];
$Alias = $_POST['Alias'];
$Correo = $_POST['Correo'];
$Ingreso = $_POST['Ingreso'];
$Pais = $_POST['Pais'];
$Estado = $_POST['Estado'];
$Ciudad = $_POST['Ciudad'];
$destinario = "[email protected]";
$asunto = "Registro de guardián";
$carta = "Nombre(s): $Nombre \n"; 
$carta .= "Apellidos: $Apellidos\n";
$carta .= "Alias: $Alias\n";
$carta .= "Correo electronico: $Correo\n";
$carta .= "Pais: $Pais\n";
$carta .= "Estado: $Estado\n";
$carta .= "Ciudad: $Ciudad";
mail($destinatario, $asunto, $carta);
 header('registroenviado.html');
?>

But when sending, these errors come out.

  

Notice: Undefined variable: recipient in /storage/ssd3/936/5718936/public_html/enviar.php on line 20

     

Warning: Can not modify header information - headers already sent by (output started at /storage/ssd3/936/5718936/public_html/enviar.php:20) in /storage/ssd3/936/5718936/public_html/enviar.php online 21

    
asked by Teresa Black SC 11.05.2018 в 20:53
source

1 answer

1

The problem is that you have declared your variable $destinario in:

$destinario = "[email protected]";

and you're calling variable $destinatario

mail($destinatario, $asunto, $carta);
 header('registroenviado.html');
?>

It's just a typing error,

Regarding the second error:

  • Check that there is not a line, white space, text, HTML or any other type of content before the tag

  • Check that there is no information output before the use of functions like setcookie (), header () or any other function that Generate or modify the HTTP headers.

answered by 11.05.2018 в 21:19