PHP表单发送2份?

PHP表单发送2份?,php,forms,email,Php,Forms,Email,我的联系方式有点奇怪 通过实际页面提交时。。www.mydomain.com/mail.php提交无误,发送电子邮件查询即可 但是,当其包含在联系人页面上时,会显示以下内容: <?php include('mail.php'); ?> 它会发送两次电子邮件,有时甚至根本不发送 有什么想法吗 <?php if (isset($_POST["mail"]) && ($_POST["mail"]=="send")) { //ini_set("sendmail

我的联系方式有点奇怪

通过实际页面提交时。。www.mydomain.com/mail.php提交无误,发送电子邮件查询即可

但是,当其包含在联系人页面上时,会显示以下内容:

<?php include('mail.php'); ?>

它会发送两次电子邮件,有时甚至根本不发送

有什么想法吗

<?php 
if (isset($_POST["mail"]) && ($_POST["mail"]=="send")) { 
//ini_set("sendmail_from", "mailserver@thedomain.com");
/******** START OF CONFIG SECTION *******/
  //$sendto  = "enquiries@rivelintravel.co.uk";
  $sendto  = "test@thedomain.com";
  $subject = "Website Form Test";
  $errorImage = "assets/form/exclamation.png";
  $acceptImage = "assets/form/accept.png";  
/******** END OF CONFIG SECTION *******/

$SpamReplaceText = "*content removed*";
// Error message prited if spam form attack found
$SpamErrorMessage = "<div class=\"contactFormErrorMessage\">Malicious code content detected.<br>Your IP Number of ".getenv("REMOTE_ADDR")." has been logged.</div>";

    foreach($_POST as $key => $value) {
        $post[$key] = $value;
    }
  $name = $post['name']; 
  $email = $post['email']; 
//  $message = $post['message']; 
  $headers = "From: $email\n";
  $headers . "MIME-Version: 1.0\n"
           . "Content-Transfer-Encoding: 7bit\n"
           . "Content-type: text/html;  charset = \"iso-8859-1\";\n\n";

// Check for Website URL's in the form input boxes as if we block website URLs from the form,
// then this will stop the spammers wastignt ime sending emails
foreach($post as $key => $value) {  
    if (preg_match("/http/i", "$post[$key]")) {echo "$SpamErrorMessage"; exit();} 
}

// Patterm match search to strip out the invalid charcaters, this prevents the mail injection spammer 
  $pattern = '/(;|\||`|>|<|&|^|"|'."\n|\r|'".'|{|}|[|]|\)|\()/i'; // build the pattern match string 

    foreach($post as $key => $value) {                       
        $post[$key] = preg_replace($pattern, "", $value); 
    }

// Check for the injected headers from the spammer attempt 
// This will replace the injection attempt text with the string you have set in the above config section
  $find = array("/bcc\:/i","/Content\-Type\:/i","/cc\:/i","/to\:/i"); 

    foreach($post as $key => $value) {                       
        $post[$key] = preg_replace($find, "$SpamReplaceText", $value); 
    } 

// Check to see if the fields contain any content we want to ban
 foreach($post as $key => $value) {  
    if(stristr($post[$key], $SpamReplaceText) !== FALSE) {echo "$SpamErrorMessage"; exit();}
} 
 // Do a check on the send email and subject text
 foreach($post as $key => $value) {  
    if(stristr($post[$key], $SpamReplaceText) !== FALSE) {echo "$SpamErrorMessage"; exit();} 
    }

// Build the email body text
$emailcontent  =  "Website Form Test" . "\n";
$emailcontent  .= "_" . "\n";

$emailcontent  .= "Name: " . $_POST['name'] . "\n";
$emailcontent  .= "Email: " . $_POST['email'] . "\n";
$emailcontent  .= "Telephone Number: " . $_POST['tel'] . "\n";
$emailcontent  .= "_" . "\n";



// Check the email address enmtered matches the standard email address format
 if (!eregi("^[A-Z0-9._%-]+@[A-Z0-9._%-]+\.[A-Z]{2,6}$", $post['email'])) { 
  echo "<div class=\"contactFormErrorMessage\"><img src=\"$errorImage\" alt=\"Error\" /><p>It appears you entered an invalid email address</p><p><a href='javascript: history.go(-1)'>Click here to go back</a></p></div>"; 
} 

 elseif (!trim($post['name'])) { 
  echo "<div class=\"contactFormErrorMessage\"><img src=\"$errorImage\" alt=\"Error\" /><p>Please go back and enter a Name</p><p><a href='javascript: history.go(-1)'>Click here to go back</a></p></div>"; 
} 


 elseif (!trim($post['email'])) { 
  echo "<div class=\"contactFormErrorMessage\"><img src=\"$errorImage\" alt=\"Error\" /><p>Please go back and enter an Email</p><p><a href='javascript: history.go(-1)'>Click here to go back</a></p></div>"; 
} 

// Sends out the email or will output the error message 
 elseif (mail($sendto, $subject, $emailcontent, $headers)) { 
  echo "<div class=\"contactFormSuccessMessage\"><img src=\"$acceptImage\" alt=\"Success\" /><p>Thank You $name<br />We will be in touch as soon as possible.</p></div>"; 

} 
}else{
?> 

<form action="<?php print $_SERVER['PHP_SELF']; ?>" method="post" id="contactForm" name="contactForm">
<input name="mail" type="hidden" value="send"/> 



<div class="content clearfix">
    <div class="left">

    <h3>Personel Details: </h3>

    <div class="field">
            <label for="name">Name <span class="required" title="This field is required.">*</span></label>
            <input name="name" type="text" />
        </div>

        <div class="field">
            <label for="email">Email Address<span class="required" title="This field is required.">*</span></label>
            <input name="email" type="text" />
        </div>

        <div class="field">
            <label for="tel">Contact Number</label>
            <input name="tel" type="text" />
        </div>

    </div>
    <!--column1-->


    <div id="sub" class="field">
        <label for="submit">&nbsp;</label>
        <input class="submit" type="submit" name="submit" value="submit" id"submit" />
    </div>


    </div>
</div><!--column-->




</fieldset>
</form>


<?php } ?>

上面的代码来自mail.php吗?可以肯定的是,mail.php不会通过联系人表单发送两次邮件?是的,上面的代码基本上就是mail.php,可以独立工作。当包含在页面中时,会发送两次电子邮件…您确定不包含两次mail.php脚本吗?你能给我们更多的代码或者contact.php吗?啊,是的,我愿意!一个表单用于桌面,另一个表单用于移动屏幕(它们出现在不同的地方),这两个表单都包含mail.php。垃圾,这周围还有什么吗?