如何添加一个"消息已发送";表单提交后显示的页面顶部的消息(现在没有显示(?以下是php文件:-
<? ob_start();
function clean_string($string) {
$bad = array("content-type","bcc:","to:","cc:","href");
return str_replace($bad,"",$string);
}
require("class.phpmailer.php");
$email = "dr_ramanand@rediffmail.com";
$subject="Quick Response";
$email_message .= "Name: ".clean_string($_POST['name'])."n";
$email_message .= "Phone: ".clean_string($_POST['phone'])."n";
$email_message .= "Email: ".clean_string($_POST['email'])."n";
$email_message .= "Address: ".clean_string($_POST['address'])."n";
$email_message .= "Subject: ".clean_string($_POST['subject'])."n";
$email_message .= "Comments: ".clean_string($_POST['comments'])."n";
$email_message .= "Keywords: ".clean_string($_POST['keywords'])."n";
$headers = "MIME-Version: 1.0rn";
$headers .= "Content-type: text/html; charset=iso-8859-1rn";
$headers .= "From: ".$from_email."rn";
$mail = new PHPMailer();
$mail->From = "dr_ramanand@rediffmail.com";
$mail->FromName = "Cure4incurables";
$mail->Subject = $subject;
$mail->Body = $email_message;
$mail->AltBody = "";//$text_body;
$mail->AddAddress($email,$name);
$mail->IsHTML(true);
if(!$mail->Send())
{
}
header("location: https://www.cure4incurables.in/Contact_Us.html");//echo "Message Sent!";
?>
<? ob_flush(); ?>
最简单的方法是向目标位置添加一个GET变量,并将该目标文件从html更改为php:
header("location: https://www.cure4incurables.in/Contact_Us.php?sent=1");
在Contact_Us.php中,您可以执行
if (isset($_GET['sent'])) {
echo "Thank you for contacting us";
}