Re: Special Chars on Form to Image (GD), not displaying properly.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Feb 22, 2006 at 01:12:00PM +0800, Louie Miranda wrote:
> Please read below..
> 
> > Im having a trouble displaying special characters like #, + on GD (Jpeg) -
> > > Image. When i typed in on the form +88 it only shows 88 and the + sign
> > is
> > > missing.
> > >
> > > My code:
> > >  <?php
> > > ..
> > > $line_1_1 = urldecode($_GET["line_1_1"]);
> >
> > You dont want to urldecode() the $_GET vars. PHP already does this
> > step.
> >
> > See what happens with:
> >
> >   var_dump(urldecode($_GET['line_1_1']));
> >   var_dump($_GET['line_1_1']);
> >
> 
> I tested this not on a GD/Image, but on a plain form and plain var_dump.
> The results:
> 
> string(1) " "
> string(1) "+"
> 
>  So, now if i even make a urldecode it also disappers. I think the problem
> is when i typed in + on the user input via form. The url converts it
> to %2B which
> i think is a space. Because as for my example (seen thru the url):
> 
> +88and#
> When displayed on an image becomes..
>  88and
> 
> Now, if i made this
> 
> +88+and#
> It displays..
>  88 and#

this is where i think your confused, the problem with your original
code is you are ending up urldecoding things twice thus thinking
that %2B == a space.

consider:
  echo urlencode(' '); # '+'
  echo urlencode('+'); # '%2B'

  echo urldecode(' ');   # ' '
  echo urldecode('+');   # ' '
  echo urldecode('%2B'); # '+'

if your url is:
  http://server.com/?foo=%2B88an%23

then in php if you do:
  echo $_GET['foo'];

you will get '+88and#'

if your url is:
  http://server.com/?foo=+88and#

then in php if you do:
  echo $_GET['foo'];

you will get: ' 88and'

> 
> It converts + to space. Now, how could i filter this properly?

Now given what I said and you have a form defined as:
<form method="GET">
  <input name="foo">
</form>

And you type in the box '+88and#' the url that is submited should
be:
  http://server.com/?foo=%2B88and%23

Then:
  echo $_GET['foo']; # '+88and#'
 
Or if you type: ' 88and#' the url should be:

  http://server.com/?foo=+88and%23

  or possibly (not to confuse things more)

  http://server.com/?foo=%2088and%23

Then:
  echo $_GET['foo']; # ' 88and#'


Now, the only way that # could seem to disappear is if you have your
form setup like:
<form method="GET" action="#">
  <input name="foo">
</form>

And you type: '+88and',  The url will look like:
  http://server.com/?foo=%2B88and#

thus:
  echo $_GET['foo']; # '+88and'

or if you type ' 88and', the url will look like:
  http://server.com/?foo=+88and#

thus:
  echo $_GET['foo']; # ' 88and'


Curt.
-- 
cat .signature: No such file or directory

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux