Sto creando un semplice form mail che sia in grado di dirmi da quale pagina del mio sito il visitatori ha mandato la segnalazione.
La pagina php dedicata all'invio dell'email è questa:
Codice PHP:
<?php
$goto_after_mail = "thanks.htm"; // this is the page which is shown after the mail is submitted
$from_mail = $_REQUEST['from_email'];
$from_name = $_REQUEST['from_name']; // use both value's from your form
$header = "From: \"$from_name\" <$from_mail>\r\n";
$header .= "MIME-Version: 1.0\r\n";
$header .= "Content-Type: text/plain; charset=\"utf-8\"\r\n";
$header .= "Content-Transfer-Encoding: 7bit\r\n";
$subject = "Your webform posted at ".date("d-m-Y"); //your mailsubject incl. current date
$page = $_SERVER['HTTP_REFERER'];
foreach ($_REQUEST as $key => $val) {
if ($key != "from_email" && $key != "from_name") { //skip, this values are already in the header
$body .= $key . " : " . $val . "\r\n";
}
}
if (mail("info@dominio.it", $subject, $body, $page, $header)) {
header("Location: ".$goto_after_mail);
}
?>
Il problema è che la pagina di provenienza non mi viene scritta nel corpo dell'e-mail ma nell'intestazione del messaggio.
Dove ho sbagliato?
Grazie mille!