Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

php / html encode

Posted on 2012-03-27
5
Medium Priority
?
745 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:Tobias
Tobias earned 400 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 111

Assisted Solution

by:Ray Paseur
Ray Paseur earned 1600 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 111

Accepted Solution

by:
Ray Paseur earned 1600 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
The first step to building an amazing About page is to figure out what you want the page to say about your company. You then must grab the attention of the reader, boast a bit, tell a story and let others brag about you. With a little bit of thought…
In this tutorial viewers will learn how to embed an audio file in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: : The declaration should display (CODE) HTML5 is supported by the most recent versions of all major browsers…
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.
Suggested Courses

885 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