PHP Mail()函数删除Â

时间:2014-02-10 14:29:37

标签: php email

在我的作品网站上使用邮件功能,它从表单中获取信息并将其邮寄给我们,但不是获得£(价格),而是获得£(价格)。

我的老板很挑剔,希望不见了。请有人帮我解决这个问题,代码如下

    <?php
if (isset($_POST['email'])) {

    // EDIT THE 2 LINES BELOW AS REQUIRED
    $email_to      = "bookings@pennycarhire.co.uk";
    $email_subject = "Returning Customer Booking Request";
    $thankyou      = "thankyou.html"; // thank you page 


    function died($error)
    {
        // your error code can go here
        echo "We are very sorry, but there were error(s) found with the form you submitted. ";
        echo "These errors appear below.<br /><br />";
        echo $error . "<br /><br />";
        echo "Please go back and fix these errors.<br /><br />";
        die();
    }

    // validation expected data exists
    if (!isset($_POST['colect2']) || !isset($_POST['coltime2']) || !isset($_POST['email']) || !isset($_POST['retur2']) || !isset($_POST['rettime2'])) {
        died('We are sorry, but there appears to be a problem with the form you submitted.');
    }



    $colect     = $_POST['colect2']; // required
    $ctime      = $_POST['coltime2']; // required
    $email_from = $_POST['email']; // required
    $return     = $_POST['retur2']; // not required
    $rtime      = $_POST['rettime2']; // required
    $car        = $_POST['cartype']; // required
    $days       = $_POST['days2']; // required
    $price      = $_POST['price2']; // required
    $waiv       = $_POST['wavco']; // required
    $toprice    = $_POST['tocost']; // required
    $name       = $_POST['name']; // required
    $dd         = $_POST['DD']; // required
    $mm         = $_POST['MM']; // required
    $yy         = $_POST['YY']; // required
    $liheld     = $_POST['liheld']; // required
    $lipart     = $_POST['lipart']; // required
    $claim      = $_POST['claim']; // required
    $phone1     = $_POST['phone1']; // required
    $qorc       = $_POST['qorc'];



    $error_message = "";


    if (strlen($rtime) < 2) {
        $error_message .= 'The Comments you entered do not appear to be valid.<br />';
    }
    if (strlen($error_message) > 0) {
        died($error_message);
    }
    $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 .= "Name: " . clean_string($name) . "\n\n";

        $email_message .= "Car Type: " . clean_string($car) . "\n\n";

        $email_message .= "Collect on: " . clean_string($colect) . "\n\n";

        $email_message .= "At: " . clean_string($ctime) . "\n\n";

        $email_message .= "Return on: " . clean_string($return) . "\n\n";

        $email_message .= "At: " . clean_string($rtime) . "\n\n";



        $email_message .= "Days: " . clean_string($days) . "\n\n";

        $email_message .= "Inclusive Price: " . clean_string($price) . "\n\n";

        $email_message .= "Waiver Ammount (If Blank No Waiver): " . clean_string($waiv) . "\n\n";

        $email_message .= "Total Cost: " . clean_string($toprice) . "\n\n";

        $email_message .= "Email: " . clean_string($email_from) . "\n\n";



        $email_message .= "Dob: " . clean_string($dd) . "/" . clean_string($mm) . "/" . clean_string($yy) . "\n\n";

        $email_message .= "Contact Number: " . clean_string($phone1) . "\n\n";

        $email_message .= "Bring both parts of licence (if no they have aggreed £3 charge): " . clean_string($lipart) . "\n\n";

        $email_message .= "Claims Or Accidents: " . clean_string($claim) . "\n\n";

        $email_message .= "Questions/Comments: " . clean_string($qorc) . "\n\n";

    }









    // create email headers
    $headers .= "Content-Type: text/html; charset=UTF-8\r\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);
?>

<!-- include your own success html here -->

<script>location.replace('<?php
    echo $thankyou;
?>')</script>

<?php
}
?>

0 个答案:

没有答案