联系表单将消息返回给发件人


Contact Form returns message to sender

我有一个网站,我最近开始,和联系形式似乎是坏了。发生的事情是,发送者提交的电子邮件将实际接收发送者试图发送的信息。而不是指定的收件人接收电子邮件。

联系人文件夹中有3个文件。

freecontactformvalidation.js

    function has_id(id){try{var tmp=document.getElementById(id).value;}catch(e){return false;}
return true;}
function has_name(nm){try{var tmp=cfrm.nm.type;}catch(e){return false;}
return true;}
function $$(id){if(!has_id(id)&&!has_name(id)){alert("Field "+id+" does not exist!'n Form validation configuration error.");return false;}
if(has_id(id)){return document.getElementById(id).value;}else{return;}}
function $val(id){return document.getElementById(id);}
function trim(id){$val(id).value=$val(id).value.replace(/^'s+/,'').replace(/'s+$/,'');}
var required={field:[],add:function(name,type,mess){this.field[this.field.length]=[name,type,mess];},out:function(){return this.field;},clear:function(){this.field=[];}};var validate={check:function(cform){var error_message='Please fix the following errors:'n'n';var mess_part='';var to_focus='';var tmp=true;for(var i=0;i<required.field.length;i++){if(this.checkit(required.field[i][0],required.field[i][1],cform)){}else{error_message=error_message+required.field[i][2]+' must be supplied'n';if(has_id(required.field[i][0])&&to_focus.length===0){to_focus=required.field[i][0];}
tmp=false;}}
if(!tmp){alert(error_message);}
if(to_focus.length>0){document.getElementById(to_focus).focus();}
return tmp;},checkit:function(cvalue,ctype,cform){if(ctype=="NOT_EMPTY"){if(this.trim($$(cvalue)).length<1){return false;}else{return true;}}else if(ctype=="EMAIL"){exp=/^[a-zA-Z0-9._%-]+@[a-zA-Z0-9.-]+'.[a-zA-Z]{2,4}$/;if($$(cvalue).match(exp)==null){return false;}else{return true;}}},trim:function(s){if(s.length>0){return s.replace(/^'s+/,'').replace(/'s+$/,'');}else{return s;}}};

index . php

    <?php include("../config.php"); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Contact  <?php echo $meta_title; ?></title>
<meta name="description" content="<?php echo $meta_desc; ?>">
<meta name="keywords" content="<?php echo $meta_keywords; ?>">
<link rel="shortcut icon" href="../images/favicon.ico" />
<link href='http://fonts.googleapis.com/css@family=Open+Sans' rel='stylesheet' type='text/css'>
<script src="freecontactformvalidation.js"></script>
    <script>
    required.add('Full_Name','NOT_EMPTY','Full Name');
    required.add('Email_Address','EMAIL','Email Address');
    required.add('Your_Message','NOT_EMPTY','Your Message');
    required.add('AntiSpam','NOT_EMPTY','Anti-Spam Question');
    </script>
    <link rel="stylesheet" type="text/css" href="freecontactform.css">
<link href="../styles.css" rel="stylesheet" type="text/css" />
<link href="../customstyles.css" rel="stylesheet" type="text/css" />
<!--ipt type="text/javascript">
  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-38670186-3']);
  _gaq.push(['_trackPageview']);
  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();
</scri--></head>
<body>
<div id="Top">
  <div id="InTop">
    <div id="NaviRight">
<div><a target="_blank" href="<?php echo $fb_url; ?>"><img src="http://socialesale.com/images/facebook-icon.jpg" alt="Facebook" width="48" height="48" border="0" class="socialicon" /></a><a target="_blank" href="<?php echo $tw_url; ?>"><img src="http://socialesale.com/images/twitter-icon.png" alt="Twitter" width="48" height="48" border="0" class="socialicon" /></a><a target="_blank" href="<?php echo $gplus_url; ?>"><img src="http://socialesale.com/images/googleplus-icon.png" alt="GooglePlus" width="48" height="48" border="0" class="socialicon" /></a><a target="_blank" href="<?php echo $youtube_url; ?>"><img src="http://socialesale.com/images/youtube-icon.png" alt="Youtube" width="48" height="48" border="0" class="socialicon" /></a><a target="_blank" href="<?php echo $pinterest_url; ?>"><img src="http://socialesale.com/images/pinterest-icon.png" alt="Pinterest" width="48" height="48" border="0" class="socialicon" /></a><a target="_blank" href="<?php echo $instagram_url; ?>"><img src="http://socialesale.com/images/instagram-icon.png" alt="Instagram" width="48" height="48" border="0" class="socialicon" /></a></div>
      <div id="Nav">
        <ul>
          <li><a href="../contact">CONTACT</a></li>
          <li><a href="../about">ABOUT</a></li>
          <li><a href="../reviews">REVIEWS</a></li>
          <li><a href="../faqs">FAQ'S</a></li>
          <li><a href="../index.php">HOME</a></li>
        </ul>
      </div>
    </div>
    <a href="../index.php"><img src="../<?php echo $logourl; ?>" alt="Social Website - Social Media Marketing" border="0" /></a></div>
</div>
<div id="Blue">
  <div id="InBlue">
    <ul>
      <li><a href="../index.php">HOME</a></li>
      <li><a href="../facebooklikes">FACEBOOK</a></li>
      <li><a href="../twitterfollowers">TWITTER</a></li>
      <li><a href="../youtubeviews">YOUTUBE</a></li>
      <li><a href="../googleplusones">GOOGLE</a></li>
      <li><a href="../instagramfollowers">INSTAGRAM</a></li>
      <li><a href="../pinterestfollowers">PINTEREST</a></li>
    </ul>
  </div>
</div>
<div id="Shad"></div>
<div id="Main">
  <div id="Info">
    <h1>Contact us</h1>
    <p>If you have any questions about the services we provide, please complete the form below and we will get back to you as soon as possible.</p>
  </div>
  <form action="contactprocess.php" method="post" name="freecontactform" id="freecontactform" onsubmit="return validate.check(this)">
    <table width="550" border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td valign="top">Your Name:</td>
      </tr>
      <tr>
        <td valign="top" class="formtd"><input name="Full_Name" type="text" class="formtxt" id="Full_Name" /></td>
      </tr>
      <tr>
        <td valign="top">Your Email Address:</td>
      </tr>
      <tr>
        <td valign="top" class="formtd"><input name="Email_Address" type="text" class="formtxt" id="Email_Address" maxlength="100" /></td>
      </tr>
      <tr>
        <td valign="top">Your Telephone Number:</td>
      </tr>
      <tr>
        <td valign="top" class="formtd"><input name="Telephone_Number" type="text" class="formtxt" id="Telephone_Number" maxlength="100" /></td>
      </tr>
      <tr>
        <td valign="top">Your Message:</td>
      </tr>
      <tr>
        <td valign="top" class="formtd"><textarea name="Your_Message" class="formtxt" id="Your_Message" style="height:160px" maxlength="2000"></textarea></td>
      </tr>
      <tr>
        <td><input name="AntiSpam" type="hidden" id="AntiSpam"  value="25" maxlength="100" />
          <div class="checkout"><a href="#" onclick="document.forms['freecontactform'].submit();">SEND EMAIL</a></div></td>
      </tr>
    </table>
    <p>&nbsp;</p>
  </form>
  <div class="clear"></div>
</div>
<div id="Bottom"><a href="../index.php">HOME</a> | <a href="../faqs">FAQ'S</a> | <a href="../reviews">REVIEWS</a>| <a href="../about">ABOUT</a> | <a href="../contact">CONTACT</a> | <a href="../purchase-agreement">PURCHASE AGREEMENT</a> | <a href="../privacy">PRIVACY POLICY</a><br />
  <br />
  Copyright 2014 &copy; <a href="<?php echo $url; ?>"><?php echo $meta_title;?>.</a>All rights reserved.</div>
</body>
</html>

contactprocess.php

    <?php
include("../config.php");
if(!$_POST) exit;
$email = $_POST['Email_Address'];
$error ="";
$errors ="";
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
    $error.="Invalid email address entered!";
    $errors=1;
}
if($errors==1) echo $error;
else{
    $values = array ('Full_Name','Email_Address','Your_Message');
    $required = array('Full_Name','Email_Address','Your_Message');

    $email_subject = "New Message From Your Social Website";
    $email_content = "new message:'n";
    foreach($values as $key => $value){
      if(in_array($value,$required)){
        if ($key != 'subject' && $key != 'company') {
          if( empty($_POST[$value]) ) { echo 'PLEASE FILL IN REQUIRED FIELDS'; exit; }
        }
        $email_content .= $value.': '.$_POST[$value]."'n";
      }
    }
    if(@mail($email,$email_subject,$email_content)) {
        echo 'Message sent!'; 
    } else {
        echo 'ERROR!';
    }
}
?>

同样在config.php中,我有这个:

    //contact form email address
$your_email = "MYEMAIL"; 

我不知道是什么问题。有人提交了一个联系表单消息,消息不是到达我的电子邮件,而是到达他们的电子邮件。所以他们的信息到达了他们的电子邮件。

希望有人能帮忙。

谢谢

在contactprocess.php中有;

//Here you store user email.
$email = $_POST['Email_Address'];
(...)
//Then here you send the email to the user
if(@mail($email,$email_subject,$email_content)) {
    echo 'Message sent!'; 
}

你想要的是:

if(@mail('OVERLOARD@EMAIL.COM',$email_subject,$email_content)) {
    echo 'Message sent!'; 
}