Mail Form + PHP + Java Script Alert error!
I have a simple mail form that is using the following php code to send the mail:
$subject="Formulário do site";
$nome = stripslashes($nome);
$morada = stripslashes($morada);
$email = stripslashes($email);
$telefone = stripslashes($telefone);
$text = stripslashes($text);
$msg = "
Nome : $nome \n
Morada : $morada \n
Email : $email \n
Telefone : $telefone \n
Mensagem : $text \n";
mail("firstname.lastname@example.org",$subject,$msg,"From: $nome <$email>");
The prob is that this code is giving me the following error after pressing the send button:
"Warning: Cannot modify header information - headers already sent by (output started at /home/vitormjl/public_html/process.php:18) in /home/vitormjl/public_html/process.php on line 19"
Can anyone help please?
that's because you have output before the header() call, which isn't allowed for obvious reasons.
Thank for the reply "theMarty"
However i´m still stuck on this. I´m still newbie at php...
Can u please tell me how to fix this?
whenever you request a page from a server, that page is sent back to you (your browser), including a whole bunch of headers. For example, the headers can tell the browser that the page doesn't exist (a 404) or that a page has been moved to a new location, so the browser can immediately redirect, etc. etc.
With the header() function you can alter these headers somewhat. But, of course this requires that no output has been sent to the users browser yet. Because, any data sent to the user, will have to be accompanied by some headers.
Ok, thanks. I guess i solved the problem.
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)