1

This is maybe a stupid problem to solve but i've looked around and i can't manage to find a viable solution.

I'm making a simple form where:

  1. the user write some text into text-areas
  2. the php must echo back those data into a simple html code to copy it somewhere else

something like this: http://www.w3schools.com/php/showphp.asp?filename=demo_form_validation_complete

but there is a problem even in the demo from w3schools: when i have some text into a *.txt file or another web page/local document and i copy(or cut) and paste it into the form and send to receive the echo it sends back a "null" value from the variable, while it doesn't happen when i type into it.

How can i solve this? Is there a way to send to the variable a copy-pasted text instead of a "null" value?

1 Answers1

0

You may have an apostrophe in the copied text and it's being converted into a curled apostrophe (see: http://www.dwheeler.com/essays/quotes-in-html.html). If you're just echoing it back out to the screen, you could wrap the $_POST['content'] in a htmlentities().

ShayneStatzell
  • 122
  • 1
  • 11
  • In my specific case it's plain text without any symbols, like a paragraph. I've tried with a lorem ipsum randomly generated and it is echoed properly, but an italian plain text echo a "null" value. I've tried to set a charset: echo htmlentities($comment, ENT_COMPAT,'ISO-8859-1', true); but it still doesn't work like i need it... Strange thing is that if i try to copy my first post entirely it is echoed like intended. – Anonimo Anonimi Sep 02 '14 at 22:28
  • EDIT: problem solved it was a conflict in the charset! Thanks for the tip anyway, that helped a lot. – Anonimo Anonimi Sep 03 '14 at 16:57