Solved

php / html encode

Posted on 2012-03-27
5
680 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 10

Assisted Solution

by:Tobias
Tobias 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 110

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 110

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

695 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