Solved

php / html encode

Posted on 2012-03-27
5
631 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 108

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 108

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
In this tutorial viewers will learn how to style transparent/translucent elements using alpha transparency in CSS Start with a normal styled element, such as a div.: Define its "background-color" property as "rgba (255, 255, 255, .5): The numbers in…
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

919 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now