Friday, March 2, 2018

javascript - PHP How to I make my textinput accept single quote or Double quotes



How do I make my textinput accept apostrophe or double quotes?




Everytime a user type's in this one: John's Birthday, I store this one in the database using mysql_real_escape_string().



What I wanted to do in here is to retrieve it in my text input.
I tried this one






The problem here is it removes the single quote and the letters that comes after the quote.

I tried to changed the value= '' from value="" but what if a user types a word that has example this one:
"You and Me". The problem is still in there.



I was thinking to use str_replace in doing this one and replace the ' into `, but again I was thinking that maybe there's an easy way to do it.



Any help would be greatly appreciated.



Thanks!


Answer



Check out this: http://www.primitivetype.com/articles/quotes_inputs.php




Basically, call htmlentities on your output before placing it in the form's value. This will turn characters like ' into the html equivalent '.



e.g.





No comments:

Post a Comment

plot explanation - Why did Peaches' mom hang on the tree? - Movies & TV

In the middle of the movie Ice Age: Continental Drift Peaches' mom asked Peaches to go to sleep. Then, she hung on the tree. This parti...