Contact.php Form Issue


Contact.php Form Issue

我的contact.php表单出现问题。它似乎间歇性工作,无法发现我做错了什么。

主机由GoDaddy提供,他们说要添加以下内容,但不确定relay-Hosting.securereserver.net 在哪里

任何关于构建其中一个的帮助或参考都将非常有用。下面是当前代码。

<?php
 if(isset($_POST['email'])) {
// EDIT THE 2 LINES BELOW AS REQUIRED
$email_to = "info@resonatebusiness.com";
$email_subject = "NEW WEBSITE INQUIRY";

$email_message = "Form details below.'n'n";
function clean_string($string) {
  $bad = array("content-type","bcc:","to:","cc:","href");
  return str_replace($bad,"",$string);
}
$email_message .= "First Name: ".clean_string($full_name)."'n";
$email_message .= "Last Name: ".clean_string($email)."'n";
$email_message .= "Email: ".clean_string($email)."'n";
$email_message .= "Telephone: ".clean_string($subject)."'n";
$email_message .= "Comments: ".clean_string($message)."'n";

$headers = 'From: '.$email_from."'r'n".
 'Reply-To: '.$email_from."'r'n" .
  'X-Mailer: PHP/' . phpversion();
  @mail($email_to, $email_subject, $email_message, $headers);  
  header("Location: http://www.publishingpush.com");
  exit;
  ?>

在发送邮件之前,您正在重定向表单。仅在成功执行邮件功能后重定向。

if( mail($email_to, $email_subject, $email_message, $headers) ){
 //redirect
}

尝试下面的代码,首先看看服务器是否正确捕获了信息并将其发送到您的电子邮件-

p.s.将thankyou.html重定向页面的位置更改为提交表单后的重定向登录页。如果这是有效的,只需调整php来过滤和预先限定您需要的信息。

<?php
/* Set e-mail recipient */
$myemail  = 'info@resonatebusiness.com'; 
/* Check all form inputs using check_input function */
$name = check_input($_POST['full_name']);
$lname = check_input($_POST['last_name']);
$email = check_input($_POST['email']);
$subject = check_input($_POST['subject']);
$spec_message = check_input($_POST['message']); 

/*E-mail Subject */
$subject = 'NEW WEBSITE INQUIRY' ;
/*From Address */
$headers = "From: $name $lname";
/* Let's prepare the message for the e-mail */
$message = "
Name: $name, $lname
E-mail: $email
Subject: $subject
Message: $spec_message
" ;
/* Send the message using mail() function */
mail($myemail, $subject, $message, $headers);
/* Redirect visitor to the thank you page */
header('Location: thankyou.html');
exit();
?>