[CLUE-Tech] PHP escaping characters

Steve Fry clue at ir3w.com
Fri Mar 1 18:01:40 MST 2002


Somewhere after you capture the variable - or before you output it
(experiment with this) - use the tag called "stripslashes" like this:

Ex.  value=\"stripslashes($yourname)\"

http://www.php.net/manual/en/function.stripslashes.php


"Jed S. Baer" wrote:
 
> 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
> _______________________________________________
> CLUE-Tech mailing list
> CLUE-Tech at clue.denver.co.us
> http://clue.denver.co.us/mailman/listinfo/clue-tech

-- 
-----------------------------------------------
              IR3W Web Services
   Steve Fry - steve at ir3w.com - 720-233-3WWW
    Web Site Design, Development, and More!
             http://www.ir3w.com
-----------------------------------------------



More information about the clue-tech mailing list