问题描述
此联系表单有问题,我无法正常使用,请帮助? 我正在使用HTML联系人表单,其操作是发送PHP脚本的邮件。但是,当我单击发送按钮时,它不起作用。请有人帮我解决这个问题。
这是contact.PHP
string StringDatetoDateTime(string date)
{
DateTime dateFormat = DateTime.Parse(date);
return dateFormat ;
}
这是网站的html部分:
<?PHP
// configure
$from = 'Demo contact form <[email protected]>';
$sendTo = '[email protected]'; // Add Your Email
$subject = 'New message from contact form';
$fields = array('name' => 'Name','subject' => 'Subject','email' => 'Email','message' => 'Message'); // array variable name => Text to appear in the email
$okMessage = 'Contact form successfully submitted. Thank you,I will get back to you soon!';
$errorMessage = 'There was an error while submitting the form. Please try again later';
// let's do the sending
try
{
$emailText = "You have new message from contact form\n=============================\n";
foreach ($_POST as $key => $value) {
if (isset($fields[$key])) {
$emailText .= "$fields[$key]: $value\n";
}
}
$headers = array('Content-Type: text/plain; charset="UTF-8";','From: ' . $from,'Reply-To: ' . $from,'Return-Path: ' . $from,);
mail($sendTo,$subject,$emailText,implode("\n",$headers));
$responseArray = array('type' => 'success','message' => $okMessage);
}
catch (\Exception $e)
{
$responseArray = array('type' => 'danger','message' => $errorMessage);
}
if (!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') {
$encoded = json_encode($responseArray);
header('Content-Type: application/json');
echo $encoded;
}
else {
echo $responseArray['message'];
}
有人可以帮助我吗?有错误吗?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)