Friday, 2 March 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

casting - Why wasn't Tobey Maguire in The Amazing Spider-Man? - Movies & TV

In the Spider-Man franchise, Tobey Maguire is an outstanding performer as a Spider-Man and also reprised his role in the sequels Spider-Man...