dry0106 2015-07-27 11:12
浏览 40

用于Bootstrap的PHP联系表单[重复]

This question already has an answer here:

I have trouble with php contact form on Bootstrap. I don't know where is problem. It always gives error message. I replaced my e-mail address there but it still gives error. I don't know which line to change.

<?php
// Check for empty fields
if(empty($_POST['name'])        ||
 empty($_POST['email'])         ||
empty($_POST['phone'])      ||
empty($_POST['message'])    ||
!filter_var($_POST['email'],FILTER_VALIDATE_EMAIL))
{
echo "No arguments Provided!";
return false;
}

$name = $_POST['name'];
$email_address = $_POST['email'];
$phone = $_POST['phone'];
$message = $_POST['message'];

// Create the email and send the message
$to = 'info@balkescafequiz.com'; // Add your email address inbetween the '' replacing yourname@yourdomain.com - This is where the form will send a message to.
$email_subject = "Website Contact Form:  $name";
$email_body = "You have received a new message from your website contact form.

"."Here are the details:

Name: $name

Email:      $email_address

Phone: $phone

Message:
$message";
$headers = "From: noreply@balkescafequiz.com
"; // This is the email address the generated message will be from. We recommend using something like noreply@yourdomain.com.
$headers .= "Reply-To: $email_address"; 
mail($to,$email_subject,$email_body,$headers);
return true;            
?>
</div>
  • 写回答

1条回答 默认 最新

  • doz97171 2015-07-27 11:17
    关注

    i didnt read trough your script, but try use this:

        //Clean string before sending
       function clean_string($string) {
      $bad = array("content-type","bcc:","to:","cc:","href");
      return str_replace($bad,"",$string);
      }
    
      //build message
      $email_message .= "$l_firstname: ".clean_string($FirstName)."
    ";
      $email_message .= "$l_lastname: ".clean_string($LastName)."
    ";
      $email_message .= "$l_email: ".clean_string($Email)."
    ";
      $email_message .= "$l_phone: ".clean_string($Phone)."
    ";
      $email_message .= "$l_msg: ".clean_string($Message)."
    ";
    
    
      $email_subject = "New Mail From "."$FullName";
    
    
      // create email headers
      $headers = 'From: '."$FullName".'<'.$Email.'>'."
    ".
      'Reply-To: '.$Email."
    " .
      'X-Mailer: PHP/' . phpversion();
      mail($Recipient, $email_subject, $email_message, $headers);
    
      //return to index, show confirmation
      header("Location: index.php?lang=$Language&show=success");
    

    This is what i use :)

    评论

报告相同问题?

悬赏问题

  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)