Quotes """ in form textarea fields
| From: | Sam Smith | Date: | Fri, 08 Oct 2004 13:22:22 +0000 |
| Subject: | Quotes """ in form textarea fields | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-198953@lists.php.net to get a copy of this message | ||
I swear I googled for an hour first.
A user enters in a textarea field of FORM1.php:
Bob is "high"
Submitted to FROM2.php we get:
Bob is \"high\"
In a hidden field in FROM2.php we store the value: <type="hidden", value="<?
echo stripslashes($_POST['textarea']); ?>> Value now Bob is "high"
Then from FROM2.php we Submit BACK to FROM1.php and enter it back into the
textarea field with:
<type="textarea", value="<? echo $_POST['hidden']); ?>
we have;
Bob is
Everything after the first double quote is clobbered.
I can fix this by putting this in FORM2.php:
$APParea1 = $_POST['textarea'];
$APParea1 = str_replace("\"","[QT]",$APParea1);
and then back by putting this in FORM1.php:
$APParea1 = $_POST['hidden'];
$APParea1 = str_replace("[QT]","\"",$APParea1);
<type="textarea", value="<? echo $APParea1; ?>
BUT THIS must have happened many times a long long time ago to many good
people and some smart function was developed, right?
Thanks