|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2001-11-06 09:17 UTC] markm at sprintout dot com
I'm experiencing a strange problem with HTML entities in form input using PHP v. 4.0.4pl1 on Apache v. 1.3.17. My form consists of three fields: A "select" pulldown menu to enable users to select an existing record (field name: "InfoID"); A text field in which users enter a headline (field name: "InfoTitle"); A textarea field in which users enter text (field name: "InfoText"). The input from the form is saved in a MySQL database (v. 3.23.33). Everything was working fine until I started adding HTML entities (e.g., ™, •, etc.) to represent the trademark symbol, bullets, etc. in the textarea field. I'm able to add a record to the database with HTML entities. However, when I retrieve an existing record, make modifications in the textarea field, and submit the input, the "selected" value from the pulldown menu is somehow lost. When I say "lost", I mean that the key for the pulldown input field is actually missing when I print out $HTTP_POST_VARS (through the print_r function) at the top of the script. If there are no HTML entities in the textarea field, the value for the pulldown menu shows up and everything works fine. I can't figure out the source of the problem. The encoding type within the <form> tag is standard: enctype="multipart/form-data". I'm not altering the input from the pulldown input field before submittal. Even odder, the same form works fine with HTML entities on older versions of PHP. Any ideas what's going on? PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Oct 25 03:00:01 2025 UTC |
With 4.0.3pl1, I cannot reproduce. Use var_dump($HTTP_POST_VARS) to check out what vars are submitted and which are not. I get: HTTP_POST_VARS: array(4) { ["InfoID"]=> string(2) "67" ["InfoTitle"]=> string(8) "Product2" ["InfoText"]=> string(196) "Blah blah blah blah? Blah blah blah blah? Blah blah blah blah. Blah blah blah blah?. Blah blah blah blah. Blah blah blah blah?. Blah blah blah blah;" ["option"]=> string(6) "Modify" } HTTP_GET_VARS: array(1) { ["selection"]=> string(11) "Description" }I can't reproduce any part of this bug report on 4.0.6. My $HTTP_POST_VARS matches jeroen's exactly for the product description script, and the following script does not translate html entities from their user-entered value. <form method="post" action="<?= $PHP_SELF ?>" enctype="multipart/form-data"> <textarea name="text" wrap="virtual"><?= htmlentities($HTTP_POST_VARS['text'])?></textarea> <br><input type="submit" value="Submit multipart"> </form> <form method="post" action="<?= $PHP_SELF ?>"> <textarea name="text" wrap="virtual"><?= htmlentities($HTTP_POST_VARS['text'])?></textarea> <br><input type="submit" value="Submit not multipart"> </form> <? if (count($HTTP_POST_VARS)) { echo '<pre>'; print_r($HTTP_POST_VARS); echo '</pre>'; } ?> I suggest taking this up on a support forum (php-general@lists.php.net, #php on irc.php.net) if it's still an issue.