Solved

php / html encode

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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
Use these top 10 tips to master the art of email signature design. Create an email signature design that will easily wow recipients, promote your brand and highlight your professionalism.
In this tutorial viewers will learn how to position overlapping items using z-index in CSS. They will also learn the restrictions on the z-index property.  Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Red.…
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

707 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