我有一个联系表单,应该发送一封包含用户当前正在观看的产品链接的电子邮件,问题是我需要使用iframe,因为服务器不接受PHP文件,所以我有:
$name = clearValue($_POST["name"]);
$lastname = clearValue($_POST["lastname"]);
$company = clearValue($_POST["company"]);
$phone = clearValue($_POST["phone"]);
$country = clearValue($_POST["country"]);
$quantity = clearValue($_POST["quantity"]);
$mail = ($_POST["mail"]);
$message = clearValue(nl2br($_POST["message"]));
$type_quote = clearValue($_POST["type"]);
$page = currentPageURL();
$headers = "Content-type: text/html\r\nFrom: $fromMailStatus \r\nReply-To: $fromMailStatus";
$body = file_get_contents("resources/mails/mail_newWebLead.htm");
$body = str_replace("{name}",$name,$body);
$body = str_replace("{lastname}",$lastname,$body);
$body = str_replace("{company}",$company,$body);
$body = str_replace("{phone}",$phone,$body);
$body = str_replace("{country}",$iPais["nombre"],$body);
$body = str_replace("{language}",$iLang["nombre"],$body);
$body = str_replace("{quantity}",$quantity,$body);
$body = str_replace("{email}",$mail,$body);
$body = str_replace("{message}",$message,$body);
$body = str_replace("{link}",$page,$body);
$body = str_replace("{ip}",$ip_source,$body);
mail($para,"New Web Lead",$body,$headers);
function currentPageURL() {
$pageURL = 'http';
if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
$pageURL .= "://";
if ($_SERVER["SERVER_PORT"] != "80") {
$pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
} else {
$pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
}
return $pageURL;
}
这样可以,但它会返回调用iFrame的页面,我需要原始的URL,我该怎么做?
答案 0 :(得分:1)
$ _ SERVER ['HTTP_REFERER']将为您提供调用页面的网址。
E.G
您的网址为http://example.com/product/12,iFrame指向http://domain.com/contact.php。
$ _ SERVER ['HTTP_REFERER']会为您提供http://example.com/product/12