Solved

php / html encode

Posted on 2012-03-27
5
636 Views
Last Modified: 2012-03-27
I am using a php mail script to post and email form contents to an email.

However when I receive the email the £ symbol is not displaying correctly.

I am getting "£" not "£".

Below is the code:

HTML Form value:

<input name="C9480A_Desc" type="hidden" id="C9480A_Desc" value="C9480A - HP 91 775ml 3 ink Matt Black @ &pound;365.00" />

Open in new window


PHP:
$_POST['C9480A_Desc']

Open in new window


I have even tried this

htmlentities ($_POST['C9480A_Desc'])

Open in new window


However I still get the same result. What am I doing wrong?
0
Comment
Question by:petewinter
  • 2
  • 2
5 Comments
 
LVL 10

Assisted Solution

by:MadShiva
MadShiva earned 100 total points
ID: 37771577
In your form try to set the charset to UTF-8 :

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
0
 
LVL 109

Assisted Solution

by:Ray Paseur
Ray Paseur earned 400 total points
ID: 37771634
It's a character-encoding issue.  Your output page may use a character encoding like UTF-8.  UTF-8 collides with many of the European ASCII characters that have ordinal values above 128.  This article explains it a little more.
http://www.joelonsoftware.com/articles/Unicode.html
0
 

Author Comment

by:petewinter
ID: 37771649
MadShiva - I have set the form header script to the below, but it doesn't solve the issue. Any idea's?

$headers = "MIME-Version: 1.0\r\n"; 
$headers .= 'Content-type: text/html; charset=UTF-8"' . "\r\n"; 

Open in new window

0
 
LVL 109

Accepted Solution

by:
Ray Paseur earned 400 total points
ID: 37771668
See http://www.laprbass.com/RAY_temp_petewinter.php
<?php // RAY_temp_petewinter.php
ini_set('display_errors', TRUE);
error_reporting(E_ALL);


// SET A CHARACTER SET THAT WORKS FOR EUROPEAN CHARACTERS
echo '<meta charset="iso-8859-1" />';


// SHOW WHAT WAS POSTED, IF ANYTHING
if (!empty($_POST))
{
    echo "<br/>";
    echo $_POST['C9480A_Desc'];
}

// CREATE A FORM WITH HEREDOC NOTATION
$form = <<<FORM
<form method="post">
<input name="C9480A_Desc" type="hidden" id="C9480A_Desc" value="C9480A - HP 91 775ml 3 ink Matt Black @ &pound;365.00" />
<br/>
<input type="submit" value="Test the £ symbol" />
</form>
FORM;

echo $form;

Open in new window

HTH, ~Ray
0
 

Author Closing Comment

by:petewinter
ID: 37772158
Many thanks
0

Featured Post

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
Finding original email is quite difficult due to their duplicates. From this article, you will come to know why multiple duplicates of same emails appear and how to delete duplicate emails from Outlook securely and instantly while vital emails remai…
In this tutorial viewers will learn how to code links for mobile sites that, once clicked, send a call or text to a specified number. For a telephone link (once clicked, calls a number), begin with a normal "<a href=" link tag. For the href, specify…
In this tutorial viewers will learn how to style a corner ribbon overlay for an image using CSS Create a new class by typing ".Ribbon":  Define the class' "display:" as "inline-block": Define its "position:" as "relative": Define its "overflow:" as …

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question