[CLUE-Tech] PHP escaping characters
    Jed S. Baer 
    thag at frii.com
       
    Fri Mar  1 17:44:26 MST 2002
    
    
  
Greetings.
I have this "one-script" php generated HTML form. Pretty simple stuff.
What happens is that if I enter a name in the name text field, like
"Duncan O'Malley", it gets changed to "Duncan O\'Malley".
It happens regardless of whether I do a get or post method. I thought any
special characters were supposed to just get URL encoded, and magically
renoberated back to whatever they were on either end.
I tried fixing this using the htmlspecialchars function, but that didn't
work, presumably because the apostrophe has already been escaped at that
point.
The form is contained in a string variable in the script:
$xform = "
// snip
<input type=\"text\" name=\"yourname\"
 size=\"40\" maxlength=\"40\"
 value=\"$yourname \"
>
// snip
";
so the first time it's called, $yourname is blank, and if the form gets
redisplayed because of validation errors, what was there is retained.
TIA
jed
-- 
"Those who expect to reap the blessings of freedom must, like men,
 undergo the fatigue of supporting it."
 - Thomas Paine
    
    
More information about the clue-tech
mailing list