0

using the mail function on my works website, it gets the info from a form and mails it to us but instead of getting £(price) we get £(price).

my boss is being fussy and wants the  gone. please can someone help me figure this out, code below

    <?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
}
?>
  • 3
    The answer can be found in the following links: http://kunststube.net/encoding/ http://kunststube.net/frontback/ http://stackoverflow.com/a/1462039/889949 http://php.net/function.iconv – DaveRandom Feb 10 '14 at 14:33
  • tried all i can to fix this, tired changing £ to \u00A3 , &pound. Changed everything i can find to encode to utf 8 . still getting the smae problem – user1385301 Feb 10 '14 at 15:28
  • 1
    Short answer: your Pounds Sterling sign is edited/encoded as UTF-8 (2 bytes), but is being displayed as a single byte encoding such as Latin-1/ISO-8859-1. I believe that email is by default Latin-1, so if you can't change it to UTF-8, you'll have to change the Pound sterling sign to Latin-1. – Phil Perry Feb 10 '14 at 15:29
  • how would i go about doing that? . change all my encoding to charset=iso-8859-1? – user1385301 Feb 10 '14 at 15:40
  • or is there anyway i could str replace to fix it? im not used to php so please excuse how bad i am – user1385301 Feb 10 '14 at 15:45
  • @user1385301 Your data is already encoded as UTF-8, but your email client is not rendering it as UTF-8. Try converting it to iso-8859-1 and stating this as your text encoding (the previously linked `iconv()` function can help you here) – DaveRandom Feb 10 '14 at 15:47

0 Answers0