【发布时间】:2013-01-07 23:41:00
【问题描述】:
我正在构建的网站上有一个简单的 PHP 联系表。提交表单时,页面刷新,然后使用 PHP 在清除的联系表单下方显示成功消息。
有什么方法可以让页面不刷新并仍然通过 Ajax 显示 PHP 成功消息,我该怎么做?
我对 PHP 很陌生。这是我当前代码的一部分...
if ($nr != $sum)
header('Location: index.php?msg=wrong#contactform');
else
// send email
$success = mail($EmailTo, $Subject, $Body, "From: <$Email>");
// redirect to success page
if ($success){
header('Location: index.php?msg=sent#contactform');
}
else{
print "<meta http-equiv=\"refresh\" content=\"0;URL=index.php\">";
}
【问题讨论】: