By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,348 Members | 1,397 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,348 IT Pros & Developers. It's quick & easy.

Posting name="abc def"

P: n/a
Hi !

If I have an input field

<form ... method="post">

<input type="text" name="abc def">

</form>

It always comes through as

$_POST["abc_def"]

I tried urlencode and rawurlencode and can't quite understand why it
is changed somwhere.

Converting " " to "_" is not quite what I want, because it should be
working with generated field names.

Any ideas?

Jochen
--
Jochen Daum - CANS Ltd.
PHP DB Edit Toolkit -- PHP scripts for building
database editing interfaces.
http://sourceforge.net/projects/phpdbedittk/
Jul 16 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
Jochen Daum wrote:
Hi !

If I have an input field

<form ... method="post">

<input type="text" name="abc def">

</form>

It always comes through as

$_POST["abc_def"]

I tried urlencode and rawurlencode and can't quite understand why it
is changed somwhere.

Converting " " to "_" is not quite what I want, because it should be
working with generated field names.

Any ideas?

Jochen


Yes. Use valid HTML.

Read the HTML 4.01 spec, specifically section 6.2:
(http://www.w3.org/TR/1999/REC-html40...tml#type-cdata)

To make it painfully obvious:
"ID and NAME tokens must begin with a letter ([A-Za-z]) and may be followed
by any number of letters, digits ([0-9]), hyphens ("-"), underscores ("_"),
colons (":"), and periods ("."). "

A space is not valid inside of a name. Therefore, you should be happy that
PHP accepts it at all. (It may actually be the browser that's changing it
too, I'm not sure... the behaviour is undefined since it's not valid HTML.)
Jul 16 '05 #2

P: n/a
Hi Agelmar!

On Thu, 14 Aug 2003 01:25:55 -0400, "Agelmar"
<if**********@comcast.net> wrote:
Jochen Daum wrote:
Hi !

If I have an input field

<form ... method="post">

<input type="text" name="abc def">

</form>

It always comes through as

$_POST["abc_def"]

I tried urlencode and rawurlencode and can't quite understand why it
is changed somwhere.

Converting " " to "_" is not quite what I want, because it should be
working with generated field names.

Any ideas?

Jochen
Yes. Use valid HTML.

Read the HTML 4.01 spec, specifically section 6.2:
(http://www.w3.org/TR/1999/REC-html40...tml#type-cdata)

To make it painfully obvious:
"ID and NAME tokens must begin with a letter ([A-Za-z]) and may be followed
by any number of letters, digits ([0-9]), hyphens ("-"), underscores ("_"),
colons (":"), and periods ("."). "


Ok, I solved it by using

name="name[keyfield1;keyfield2]"

which at least works with spaces. Not a good idea I know.

However, . is turned into underscore by PHP, though its valid HTML
obviously. Just wondered, why this is.

Jochen

A space is not valid inside of a name. Therefore, you should be happy that
PHP accepts it at all. (It may actually be the browser that's changing it
too, I'm not sure... the behaviour is undefined since it's not valid HTML.)


--
Jochen Daum - CANS Ltd.
PHP DB Edit Toolkit -- PHP scripts for building
database editing interfaces.
http://sourceforge.net/projects/phpdbedittk/
Jul 16 '05 #3

P: n/a
On Thu, 14 Aug 2003 01:25:55 -0400, "Agelmar"
<if**********@comcast.net> wrote:
Jochen Daum wrote:
If I have an input field

<form ... method="post">

<input type="text" name="abc def">

</form>

It always comes through as

$_POST["abc_def"]

I tried urlencode and rawurlencode and can't quite understand why it
is changed somwhere.

Converting " " to "_" is not quite what I want, because it should be
working with generated field names.

Any ideas?

Jochen
Yes. Use valid HTML.


The above is valid HTML.
Read the HTML 4.01 spec, specifically section 6.2:
(http://www.w3.org/TR/1999/REC-html40...tml#type-cdata)

To make it painfully obvious:
"ID and NAME tokens must begin with a letter ([A-Za-z]) and may be followed
by any number of letters, digits ([0-9]), hyphens ("-"), underscores ("_"),
colons (":"), and periods ("."). "

A space is not valid inside of a name. Therefore, you should be happy that
PHP accepts it at all. (It may actually be the browser that's changing it
too, I'm not sure... the behaviour is undefined since it's not valid HTML.)


The name attribute of the INPUT element is defined in the HTML DTD to
be of type CDATA, not of the restricted types ID or NAME.

There are no further restrictions on the values of the INPUT name
attribute listed in the specification.

See:

http://groups.google.com/groups?hl=e...3.30&frame=off

... starting with David K. Wall's post that made the same assertion,
and read mine and Tad McLellan's replies.

PHP applies its own restrictions on accepted values of the name
attribute, presumably inherited from the register_globals=on days;
names are restricted to those that are valid for PHP variable names,
and are rewritten using underscores for invalid characters.

Jul 16 '05 #4

P: n/a
Agelmar wrote:
Jochen Daum wrote:
Hi Agelmar!

On Thu, 14 Aug 2003 01:25:55 -0400, "Agelmar"
<if**********@comcast.net> wrote:
Jochen Daum wrote:
Hi !

If I have an input field

<form ... method="post">

<input type="text" name="abc def">

</form>

It always comes through as

$_POST["abc_def"]

I tried urlencode and rawurlencode and can't quite understand why
it is changed somwhere.

Converting " " to "_" is not quite what I want, because it should
be working with generated field names.

Any ideas?

Jochen

Yes. Use valid HTML.

Read the HTML 4.01 spec, specifically section 6.2:
(http://www.w3.org/TR/1999/REC-html40...tml#type-cdata)

To make it painfully obvious:
"ID and NAME tokens must begin with a letter ([A-Za-z]) and may be
followed by any number of letters, digits ([0-9]), hyphens ("-"),
underscores ("_"), colons (":"), and periods ("."). "


Ok, I solved it by using

name="name[keyfield1;keyfield2]"

which at least works with spaces. Not a good idea I know.

However, . is turned into underscore by PHP, though its valid HTML
obviously. Just wondered, why this is.

Jochen


No, it is not valid HTML. You are using a semicolon. This is not
valid. You can only use letters, numbers, hyphens, underscores,
colons, and periods. You may *not* use a semicolon. Did you even read
what I posted?


Hmm, nevermind, it seems as if I am incorrect. Read Andy's post for more
information.

Sorry.
Jul 16 '05 #5

P: n/a
Andy Hassall wrote:
On Thu, 14 Aug 2003 01:25:55 -0400, "Agelmar"
<if**********@comcast.net> wrote:
Jochen Daum wrote:
If I have an input field

<form ... method="post">

<input type="text" name="abc def">

</form>

It always comes through as

$_POST["abc_def"]

I tried urlencode and rawurlencode and can't quite understand why it
is changed somwhere.

Converting " " to "_" is not quite what I want, because it should be
working with generated field names.

Any ideas?

Jochen
Yes. Use valid HTML.


The above is valid HTML.
Read the HTML 4.01 spec, specifically section 6.2:
(http://www.w3.org/TR/1999/REC-html40...tml#type-cdata)

To make it painfully obvious:
"ID and NAME tokens must begin with a letter ([A-Za-z]) and may be
followed
by any number of letters, digits ([0-9]), hyphens ("-"), underscores
("_"),
colons (":"), and periods ("."). "

A space is not valid inside of a name. Therefore, you should be
happy that
PHP accepts it at all. (It may actually be the browser that's
changing it
too, I'm not sure... the behaviour is undefined since it's not valid
HTML.)


The name attribute of the INPUT element is defined in the HTML DTD to
be of type CDATA, not of the restricted types ID or NAME.

There are no further restrictions on the values of the INPUT name
attribute listed in the specification.

See:

http://groups.google.com/groups?hl=e...3.30&frame=off
... starting with David K. Wall's post that made the same assertion,
and read mine and Tad McLellan's replies.

PHP applies its own restrictions on accepted values of the name
attribute, presumably inherited from the register_globals=on days;
names are restricted to those that are valid for PHP variable names,
and are rewritten using underscores for invalid characters.


Hmm... interesting. Good to know. Personally though, I'll stick with names
valid in C :-)

Sorry to the original poster for my incorrect reply.
Jul 16 '05 #6

P: n/a
In article <o2********************************@4ax.com>,
jo*********@cans.co.nz says...
Hi Agelmar!

On Thu, 14 Aug 2003 01:25:55 -0400, "Agelmar"
<if**********@comcast.net> wrote:
Jochen Daum wrote:
Hi !

If I have an input field

<form ... method="post">

<input type="text" name="abc def">

</form>

It always comes through as

$_POST["abc_def"]

I tried urlencode and rawurlencode and can't quite understand why it
is changed somwhere.

Converting " " to "_" is not quite what I want, because it should be
working with generated field names.

Any ideas?

Jochen


Yes. Use valid HTML.

Read the HTML 4.01 spec, specifically section 6.2:
(http://www.w3.org/TR/1999/REC-html40...tml#type-cdata)

To make it painfully obvious:
"ID and NAME tokens must begin with a letter ([A-Za-z]) and may be followed
by any number of letters, digits ([0-9]), hyphens ("-"), underscores ("_"),
colons (":"), and periods ("."). "


Ok, I solved it by using

name="name[keyfield1;keyfield2]"

which at least works with spaces. Not a good idea I know.

However, . is turned into underscore by PHP, though its valid HTML
obviously. Just wondered, why this is.

Jochen

A space is not valid inside of a name. Therefore, you should be happy that
PHP accepts it at all. (It may actually be the browser that's changing it
too, I'm not sure... the behaviour is undefined since it's not valid HTML.)



Well, the . is the concatenation operator in PHP, so they need to be
changed to something that is valid in a PHP variable name.

--
Quod subigo farinam

$email =~ s/oz$/au/o;
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet?
Jul 16 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.