Discussion:
Plus sign changing to space in html form
Stan
2002-10-28 23:26:39 UTC
Permalink
When i post a string containing plus sign with htmp form to a php scritp,
the '+' is changed to space.
e.g: i enter 'as+df' to a text input but $_POST[] returns 'as df' instead.
It must be in php or apache configuration bcause i have this problem only on
sytem with FreeBSD. On windows it works as expected.

Know someone how could i make the '+' left intact? Please help.


<?
echo $_POST['test'];
?>
<form actiom='test.php' method=POST>
<input type=text value='' name=test>
<input type=submit value='submit'>
</form>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Tom Woody
2002-10-29 00:00:46 UTC
Permalink
I did your little test and couldn't reproduce the problems you are
having. as+df gets returned correctly.

Test server: Apache 1.3.23-11 w/ PHP 4.1.2-7 (RH7.3 rpms)

On Tue, 29 Oct 2002 00:26:39 +0100
Post by Stan
When i post a string containing plus sign with htmp form to a php
scritp, the '+' is changed to space.
e.g: i enter 'as+df' to a text input but $_POST[] returns 'as df'
instead. It must be in php or apache configuration bcause i have this
problem only on sytem with FreeBSD. On windows it works as expected.
Know someone how could i make the '+' left intact? Please help.
<?
echo $_POST['test'];
?>
<form actiom='test.php' method=POST>
<input type=text value='' name=test>
<input type=submit value='submit'>
</form>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--
Tom Woody
Systems Administrator
NationWide Flood Research, Inc.
phone: 214-631-0400 x209
fax: 214-631-0800

Don't throw your computer out the window,
throw the Windows out of your computer!
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
John W. Holmes
2002-10-29 00:20:07 UTC
Permalink
The plus sign is used to signify a space in some URL encoding. PHP is
probably thinking the text is encoded and it's removing the plus sign.
Not sure on a solution.

---John Holmes...
-----Original Message-----
Sent: Monday, October 28, 2002 6:27 PM
Subject: [PHP] Plus sign changing to space in html form
When i post a string containing plus sign with htmp form to a php scritp,
the '+' is changed to space.
e.g: i enter 'as+df' to a text input but $_POST[] returns 'as df' instead.
It must be in php or apache configuration bcause i have this problem
only
on
sytem with FreeBSD. On windows it works as expected.
Know someone how could i make the '+' left intact? Please help.
<?
echo $_POST['test'];
?>
<form actiom='test.php' method=POST>
<input type=text value='' name=test>
<input type=submit value='submit'>
</form>
--
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
Chris Shiflett
2002-10-29 01:46:51 UTC
Permalink
This is true, but the + itself should also be encoded.

I did a quick test, and when I post a form variable called test with a
value of 1+1=2, the HTTP request looks like this:

POST /test.php HTTP/1.1
Host: 127.0.0.1
User-Agent: Mozilla/5.0 Galeon/1.2.6 (X11; Linux i686; U;) Gecko/20020916
Accept:
text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,video/x-mng,image/png,image/jpeg,image/gif;q=0.2,text/css,*/*;q=0.1
Accept-Language: en
Accept-Charset: ISO-8859-1, utf-8;q=0.66, *;q=0.66
Keep-Alive: 300
Connection: keep-alive
Content-Type: application/x-www-form-urlencoded
Content-Length: 14

test=1%2B1%3D2

So, that %2B would have to get decoded twice to result in a space.

Stan, do you have a way to see what the HTTP request is? You mention
being on a BSD box, so I assume you have tcpdump? Also, is this behavior
consistent with different browsers?

Chris
Post by John W. Holmes
The plus sign is used to signify a space in some URL encoding. PHP is
probably thinking the text is encoded and it's removing the plus sign.
Not sure on a solution.
---John Holmes...
-----Original Message-----
Sent: Monday, October 28, 2002 6:27 PM
Subject: [PHP] Plus sign changing to space in html form
When i post a string containing plus sign with htmp form to a php scritp,
the '+' is changed to space. e.g: i enter 'as+df' to a text input but $_POST[] returns 'as df' instead.
It must be in php or apache configuration bcause i have this problem only
on sytem with FreeBSD. On windows it works as expected.
Know someone how could i make the '+' left intact? Please help.
<?
echo $_POST['test'];
?>
<form actiom='test.php' method=POST>
<input type=text value='' name=test>
<input type=submit value='submit'>
</form>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Stan
2002-10-29 12:01:25 UTC
Permalink
I dont know how to see the http request. tcpdump on FreeBSD requires read
access to /dev/bpf0 which i dont have.

Different browsers works the same.
Post by Chris Shiflett
This is true, but the + itself should also be encoded.
I did a quick test, and when I post a form variable called test with a
POST /test.php HTTP/1.1
Host: 127.0.0.1
User-Agent: Mozilla/5.0 Galeon/1.2.6 (X11; Linux i686; U;) Gecko/20020916
text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=
0.8,video/x-mng,image/png,image/jpeg,image/gif;q=0.2,text/css,*/*;q=0.1
Post by Chris Shiflett
Accept-Language: en
Accept-Charset: ISO-8859-1, utf-8;q=0.66, *;q=0.66
Keep-Alive: 300
Connection: keep-alive
Content-Type: application/x-www-form-urlencoded
Content-Length: 14
test=1%2B1%3D2
So, that %2B would have to get decoded twice to result in a space.
Stan, do you have a way to see what the HTTP request is? You mention
being on a BSD box, so I assume you have tcpdump? Also, is this behavior
consistent with different browsers?
Chris
Post by John W. Holmes
The plus sign is used to signify a space in some URL encoding. PHP is
probably thinking the text is encoded and it's removing the plus sign.
Not sure on a solution.
---John Holmes...
-----Original Message-----
Sent: Monday, October 28, 2002 6:27 PM
Subject: [PHP] Plus sign changing to space in html form
When i post a string containing plus sign with htmp form to a php scritp,
the '+' is changed to space. e.g: i enter 'as+df' to a text input but
$_POST[] returns 'as df' instead.
Post by Chris Shiflett
Post by John W. Holmes
It must be in php or apache configuration bcause i have this problem only
on sytem with FreeBSD. On windows it works as expected.
Know someone how could i make the '+' left intact? Please help.
<?
echo $_POST['test'];
?>
<form actiom='test.php' method=POST>
<input type=text value='' name=test>
<input type=submit value='submit'>
</form>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Stan
2002-10-29 13:14:56 UTC
Permalink
When i enter
1%2B1%3D2
to the input form and submit, the result is
1+1=2

It looks like the http request received by php is not
"application/x-www-form-urlencoded" but php thinks that it is.
I dont know what to think about that.
Post by Chris Shiflett
This is true, but the + itself should also be encoded.
I did a quick test, and when I post a form variable called test with a
POST /test.php HTTP/1.1
Host: 127.0.0.1
User-Agent: Mozilla/5.0 Galeon/1.2.6 (X11; Linux i686; U;) Gecko/20020916
text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=
0.8,video/x-mng,image/png,image/jpeg,image/gif;q=0.2,text/css,*/*;q=0.1
Post by Chris Shiflett
Accept-Language: en
Accept-Charset: ISO-8859-1, utf-8;q=0.66, *;q=0.66
Keep-Alive: 300
Connection: keep-alive
Content-Type: application/x-www-form-urlencoded
Content-Length: 14
test=1%2B1%3D2
So, that %2B would have to get decoded twice to result in a space.
Stan, do you have a way to see what the HTTP request is? You mention
being on a BSD box, so I assume you have tcpdump? Also, is this behavior
consistent with different browsers?
Chris
Post by John W. Holmes
The plus sign is used to signify a space in some URL encoding. PHP is
probably thinking the text is encoded and it's removing the plus sign.
Not sure on a solution.
---John Holmes...
-----Original Message-----
Sent: Monday, October 28, 2002 6:27 PM
Subject: [PHP] Plus sign changing to space in html form
When i post a string containing plus sign with htmp form to a php scritp,
the '+' is changed to space. e.g: i enter 'as+df' to a text input but
$_POST[] returns 'as df' instead.
Post by Chris Shiflett
Post by John W. Holmes
It must be in php or apache configuration bcause i have this problem only
on sytem with FreeBSD. On windows it works as expected.
Know someone how could i make the '+' left intact? Please help.
<?
echo $_POST['test'];
?>
<form actiom='test.php' method=POST>
<input type=text value='' name=test>
<input type=submit value='submit'>
</form>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Phoebe Bright
2002-10-31 09:50:20 UTC
Permalink
I am battling with the same problem on both IE and Netscape on Mac OS
10.2. Is this a Mac thing?

I ammended your code in the hope that something was being passed that
only looked like a space..

<?php
echo $_POST['test'].'<br>';
for($n=1;$n<=strlen($_POST['test']);$n++) {
echo var_dump(hexdec(substr($_POST['test'],$n-1,1)));
}
php?>
<form actiom='test.php' method=POST>
<input type=text value='' name=test>
<input type=submit value='submit'>
</form>


If I enter a+b it returns:
a b
int(10) int(0) int(11)

I can't ask users to enter a<PLUS>b or some such code, there must be a
solution. I don't belive this is going to defeat the collective brains
of the PHP list!

Phoebe.
Post by Stan
When i post a string containing plus sign with htmp form to a php scritp,
the '+' is changed to space.
e.g: i enter 'as+df' to a text input but $_POST[] returns 'as df' instead.
It must be in php or apache configuration bcause i have this problem only on
sytem with FreeBSD. On windows it works as expected.
Know someone how could i make the '+' left intact? Please help.
<?
echo $_POST['test'];
?>
<form actiom='test.php' method=POST>
<input type=text value='' name=test>
<input type=submit value='submit'>
</form>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Phoebe Bright
2002-10-31 11:46:50 UTC
Permalink
Here is a fudge that uses Javascript to convert the + into {PLUS} then
PHP converts it back again. The only problem is Javascript is only
converting the first +, so a+b+c becomes a+b c.


<?php
$testVal=str_replace("{PLUS}","+",$_POST['test']);
echo $testVal;
php?>
<script>
function SaveHiddenChars() {
document.form1.test.value=document.form1.test.value.replace("+","{PLUS}");
}
</script>
<form name="form1" actiom='test.php' method=POST
onSubmit="SaveHiddenChars();">
<input type=text value='' name=test>
<input type=submit value='submit'>
</form>
Post by Stan
When i post a string containing plus sign with htmp form to a php scritp,
the '+' is changed to space.
e.g: i enter 'as+df' to a text input but $_POST[] returns 'as df' instead.
It must be in php or apache configuration bcause i have this problem only on
sytem with FreeBSD. On windows it works as expected.
Know someone how could i make the '+' left intact? Please help.
<?
echo $_POST['test'];
?>
<form actiom='test.php' method=POST>
<input type=text value='' name=test>
<input type=submit value='submit'>
</form>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Loading...