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
<input type='text' name='title' value='<?php echo $values->title; ?>' />
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开发者_如何学JAVA 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!
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.
<input ... value='<?php echo htmlentities($values->title, ENT_QUOTES); ?>' />
You can replace double quotes with "
. '
for single quotes.
Replace single quote with ‘
精彩评论