NYCPHP Meetup

NYPHP.org

[nycphp-talk] HTML entities in posted variables problem

Chris Bielanski Cbielanski at inta.org
Wed Mar 17 09:57:56 EST 2004


Check the manual for the htmlspecialchars(), urlencode() and urldecode()
functions. Unless I'm missing the point, these functions should make it
fairly simple for you to convert the entities or encoding in the request
vars back into plaintext. If that's not helpful, Read The Fine Manual about
string data, and the differences in single- and double-quoted string
contructs, particularly where it concerns using the backslash character to
escape other characters within a string.

HTH
~Chris

> -----Original Message-----
> From: DeWitt, Michael [mailto:mjdewitt at alexcommgrp.com]
> Sent: Wednesday, March 17, 2004 9:43 AM
> To: 'NYPHP Talk'
> Subject: [nycphp-talk] HTML entities in posted variables problem
> 
> 
> Does anyone have a good idea of the best way to handle HTML 
> entities in post
> variables?  It seems that the entity will be converted to a rendered
> character when the page returns making checks of the string 
> used to set the
> value against the returned (posted) value will fail.
> 
> For example
> 
> // ’ is the close quote
> 
> $a='Yes, It’s true';
> 
> echo '<input type="radio" name="q1" value="'.$a.'">'.$a;
> 
> .
> .
> .
> 
> if ($a==$_post['q1']) {
> 	echo 'A miracle happened';
> 
> }
> 
> Checking $_post['q1'], I find it is equal to "Yes it's true"
> I have played around with other entities and it doesn't seem 
> to be an issue
> with just  quotes.
> 
> Does anyone have an idea of why this is happening and, 
> perhaps, the best way
> to handle this?  
> 
> I believe a similar question was posted back on the 2nd by 
> Rahmin, but I
> couldn't find any responses.  
> 
> Mike
> 
>  
> _______________________________________________
> talk mailing list
> talk at lists.nyphp.org
> http://lists.nyphp.org/mailman/listinfo/talk
> 



More information about the talk mailing list