您好我希望有人帮我添加功能标题(位置:thankyou.html)或其他一些将成功发送的电子邮件重定向到感谢页面的功能。我在我的脚本上尝试了几种方法(我已经预先填充了这些方法)并且它不起作用。
该脚本附带3个文件:targetform.js,config_email.php和engine.php
我特此写下三个文件的完整脚本
targetform.js
$(document).ready(function() {
//botton form click
$("#bottone-contact").click(function(){
$(this).hide();
$("<img src='Images/loader.gif' class='loader' />").appendTo("#contact");
var timer = 2000;
//associo variabili generali
var nome = $("#nome").val();
var messaggio = $("#messaggio").val();
var email = $("#email").val();
var oggetto = $("#oggetto").val();
var informativa = $("#informativa").attr('checked');
//pattern email
var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
if(!emailReg.test(email)) {
$("#bottone-contact").show();
$("<div id='errori'></div>").appendTo("#contact").html("<span>Ooopsss! You may have typed your email in an uncorrect way! Check if the @ is present</span>").delay(2000).fadeOut(timer);
$(".loader").hide();
} else if(informativa != "checked"){
alert("You must accept the statement on the privacy data treatment in order to continue!");
$("#bottone-contact").show();
$(".loader").hide();
} else if (nome == "" || email == "" ) {
$("#bottone-contact").show();
$("<div id='errori'></div>").appendTo("#contact").html("<span>Fill in all the fields with the asterisk!</span>").delay(2000).fadeOut(timer);
$(".loader").hide();
} //se ci sono campi vuoti
else { //se sono stati compilati tutti i campi
//chiamata ajax
$.ajax({
type: "POST",
url: "form/engine.php",
//il form invia i dati all'engine
data: "nome=" + nome + "&email=" + email + "&messaggio=" + messaggio + "&oggetto=" + oggetto,
dataType: "html",
success: function(msg)
{
//Imposta il valore dei campi di testo come vuoto grazie a val()
$(".loader").hide();
$("<div id='risultato'></div>").appendTo('#contact').html("<span>Email sent with success!</span>").delay(3000).fadeOut(timer);
$("#bottone-contact").delay(2000).fadeIn();
},
error: function()
{
alert("An unexpected error has occurred....");
}
});
}//else controlli
}); //fine form
});//Fine Dom
engine.php
<?php
//Includo Variabili
include('config_email.php');
session_start();
$nome = $_POST['nome'];
$email = $_POST['email'];
$oggetto = $_POST['oggetto'];
$messaggio = $_POST['messaggio'];
$ip = $_SERVER['REMOTE_ADDR'];
if (empty($_POST['nome'])):
exit;
else:
//Codice normale di invio
endif;
//Verifica antispam
if($_POST['fred'] != "") {
echo('<p style="color: #000; font-size: 25px; font-weight: bold;">Are you a spambot or are you using undesired spam techniques? Sorry but your email has not been sent</p>');
}
else {
//Invio la mail
$to = $tua_email;
$sbj = "Richiesta Informazioni - $sito_internet";
$msg = "
<html>
<head>
<style type='text/css'>
body{
font-family:'Lucida Grande', Arial;
color:#333;
font-size:15px;
}
</style>
</head>
<body>
<table width='600' border='0' cellspacing='0' cellpadding='5'>
<tr>
<td width='121' align='right' valign='baseline'><strong>Nome:</strong></td>
<td width='459'>$nome</td>
</tr>
<tr>
<td align='right' valign='baseline'><strong>Email:</strong></td>
<td>$email</td>
</tr>
<tr>
<td width='121' align='right' valign='baseline'><strong>Oggetto:</strong></td>
<td width='459'>$oggetto</td>
</tr>
<tr>
<td align='right' valign='baseline'><strong>Richiesta:</strong></td>
<td>$messaggio</td>
</tr>
<tr>
<td align='right' valign='baseline'><strong>IP Tracciato (per motivi di sicurezza):</strong></td>
<td>$ip</td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td><small>Powered by Targetweb.it | © Copyright 2012 Riccardo Mel</small></td>
</tr>
</table>
</body>
</html>
";
$from = $email;
$headers = "MIME-Version: 1.0\n";
$headers .= "Content-type: text/html; charset=utf-8\n"; //In certi casi con aruba se non viene formattata eliminare il \r per i permessi come ho fatto in questo caso
$headers .= "From: $from";
mail($to,$sbj,$msg,$headers); //Invio mail principale.
//Fine mail inviata a me
//Inizio email di conferma
$toClient = $email;
$msgClient = "
<html>
<head>
<style type='text/css'>
body{
font-family:'Lucida Grande', Arial;
color:#333;
font-size:15px;
}
</style>
</head>
<body>
<h1>Versilia Rent</h1>
<br />
<h2>www.versiliarent.com</h2>
<h2>Automatic response</h2>
<br />
<p>Thanks for contact us, $nome</p>
<p>We received your email. We will answer as soon as possible.</p>
</body>
</html>
";
$fromClient = $tua_email;
$sbjClient = "Response to your information request Versilia Rent";
$headersClient = 'MIME-Version: 1.0' . "\r\n";
$headersClient .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headersClient .= "From: $fromClient";
mail($toClient,$sbjClient,$msgClient,$headersClient); //mail inviata al cliente
//Fine email di conferma
//Resetto errori
session_destroy();
exit;
} //fine else del controllo antispam
?>
config_email.php
<?php
//file di configurazione variabili
$tua_email = "n.pagnoni@alice.it";
$sito_internet = "Versilia Rent";
$grazie = "http://www.versiliarent.it";
?>
我想我应该添加以下内容
标题(&#39;位置:page.php&#39;);
我想我应该在targetform.js文件的部分输入它,该文件在行之后给出说明
成功:功能(msg) {
但它不起作用。我也试过了
window.open
但又一无所获。
感谢您的帮助! (注意:我写在这里,因为脚本的作者没有回答我的问题,可能会在几周内完成) 埃琳娜
答案 0 :(得分:0)
我解决了这个问题。我刚刚添加了以下内容:
success: function(msg)
{
$(".loader").hide();
$("<div id='risultato'></div>").appendTo('#contact').html("<span>Email sent with success!</span>").delay(3000).fadeOut(timer);
$("#bottone-contact").delay(2000).fadeIn();
window.location='http://www.versiliarent.com/thanks.html'
},