PHPmailer如何显示消息
单击表单中的“发送”后如何显示成功消息?我的phpmailer正在工作,但我想在单击发送后重定向到我的主页(index.html)并显示我的消息div。这是我的php代码PHPmailer如何显示消息,php,jquery,phpmailer,Php,Jquery,Phpmailer,单击表单中的“发送”后如何显示成功消息?我的phpmailer正在工作,但我想在单击发送后重定向到我的主页(index.html)并显示我的消息div。这是我的php代码 <?php require 'phpmailer/PHPMailerAutoload.php'; $mail = new PHPMailer; $subject = $_POST['subject']; $name = $_POST['name']; $email = $_POST['email']; $messag
<?php
require 'phpmailer/PHPMailerAutoload.php';
$mail = new PHPMailer;
$subject = $_POST['subject'];
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
//$mail->SMTPDebug = 3; // Enable verbose debug output
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = 'mail.xxxxxxx.pl'; // Specify main and backup SMTP servers
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = 'xxxxx@xxxxxxxx.pl'; // SMTP username
$mail->Password = 'password'; // SMTP password
$mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
$mail->Port = 587; // TCP port to connect to
$mail->setFrom($email, $name);
$mail->addAddress('xxxx@gmail.com', 'xxxxxxxx'); // Add a recipient // Name is optional
$mail->isHTML(true); // Set email format to HTML
$mail->Subject = $subject;
$mail->Body = 'Body test';
if(!$mail->send()) {
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
} else {
header('Location: index.html');
}
您可以随请求发送额外的参数:
header('Location: index.php?r=1');
然后在索引页中获取参数并使用它显示框:
<script>
var result="<?php echo $_GET['r']; ?>";
if(parseInt(result)){
$('.box-up').animate({top : 150}, 'normal').delay(3000).animate({top : -500}, 'normal');
}
</script>
var结果=”;
if(parseInt(结果)){
$('.box-up')。动画({top:150},'normal')。延迟(3000)。动画({top:-500},'normal');
}
希望这有帮助。您可以在请求时发送额外的参数:
header('Location: index.php?r=1');
然后在索引页中获取参数并使用它显示框:
<script>
var result="<?php echo $_GET['r']; ?>";
if(parseInt(result)){
$('.box-up').animate({top : 150}, 'normal').delay(3000).animate({top : -500}, 'normal');
}
</script>
var结果=”;
if(parseInt(结果)){
$('.box-up')。动画({top:150},'normal')。延迟(3000)。动画({top:-500},'normal');
}
希望这有帮助。您必须将消息存储在某个位置,然后安排html页面显示它。您必须将消息存储在某个位置,然后安排html页面显示它。因此,我必须将index.html另存为index.php,并将此代码添加到我的js文件中?您应该调试以了解问题的来源,例如,尝试显示
警报(结果)代码>;当我使用alert进行调试时,返回数字1,这样应该可以工作,但jquery不工作。在我的本地主机中,这个jquery可以正常显示和隐藏div。因此我必须将index.html保存为index.php,并将此代码添加到我的js文件中?您应该进行调试以了解问题的来源,例如尝试显示警报(结果)代码>;当我使用alert进行调试时,返回数字1,这样应该可以工作,但jquery不工作。在我的本地主机中,这个jquery正常工作,显示和隐藏div。