RE: [PHP] plus sign has changed to space after POST
| From: | bhkwan at ThoughtWorks dot com | Date: | Wed, 20 Nov 2002 00:27:46 +0000 |
| Subject: | RE: [PHP] plus sign has changed to space after POST | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-125168@lists.php.net to get a copy of this message | ||
might be my php code has problem the following code fragment will keep "+"
to "+" but "$" to "%24"
<?
echo urlencode($_POST['test']);
?>
<form action='testp.php' method=POST>
<input type=text value='' name=test>
<?php
$test=urldecode($test);
?>
<input type=submit value='submit'>
</form>
"John W. Holmes" <holmes072000@charter.net>
11/19/2002 04:12 PM
Please respond to holmes072000
To: <bhkwan@ThoughtWorks.com>
cc: <php-general@lists.php.net>
Subject: RE: [PHP] plus sign has changed to space after POST
You have to encode it on one end, and decode it on the other.
Use
$url_safe = urlencode($string);
and pass $url_safe in the URL. Then on the receiving end, use
$back_to_normal = urldecode($url_safe_string);
---John Holmes...
> -----Original Message-----
> From: bhkwan@ThoughtWorks.com [mailto:bhkwan@ThoughtWorks.com]
> Sent: Tuesday, November 19, 2002 7:06 PM
> To: holmes072000@charter.net
> Cc: bhkwan@ThoughtWorks.com; php-general@lists.php.net
> Subject: RE: [PHP] plus sign has changed to space after POST
>
> I have tried this but the problem is it change the other special
character
> as well. For example, $ to %24, etc.
>
> If people pass a string like "abc+def$ghi", I want to save the exact
> string to the database rather than "abc+def%24ghi". I can't do a
> translation of %24 to $ before saving the string to the database
because
> user might input a string like "abc+%3423324hello%23ddd"
>
>
>
>
>
>
> "John W. Holmes" <holmes072000@charter.net>
> 11/19/2002 03:52 PM
> Please respond to holmes072000
>
>
> To: <bhkwan@ThoughtWorks.com>, <php-general@lists.php.net>
> cc:
> Subject: RE: [PHP] plus sign has changed to space after
> POST
>
>
> > -----Original Message-----
> > From: bhkwan@ThoughtWorks.com [mailto:bhkwan@ThoughtWorks.com]
> > Sent: Tuesday, November 19, 2002 6:43 PM
> > To: php-general@lists.php.net
> > Subject: [PHP] plus sign has changed to space after POST
> >
> > After upgrade to 4.2.3, plus "+" sign has changed to space after
POST.
> I
> > have checked the mailing list but can't find any help to turn this
off
> > forever! is this a bug in PHP?
> >
> > thanks
>
> Spaces are encoded as plus signed or %20 in the URL, depending on the
> method you use. PHP will automatically urldecode() the values passed
in
> the URL apparently. If you are trying to pass an actual + sign, you
need
> to encode it with urlencode() or rawurlencode().
>
> ---John Holmes...
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php