Reputation: 739
I have an HTML form:
<html>
<body>
<form method="post" action="test.php">
<input type="text" name=" TEST " value=" TEST "/>
<input type="submit" />
</form>
</body>
</html>
It submits to the following PHP page:
<?php
var_dump($_POST);
When I submit the form without modifying any values, the resulting page displays:
array(1) { ["TEST___"]=> string(12) " TEST " }
Where did the left spaces/underscores go in the key name? How can I get the left spaces/underscores back?
Upvotes: 2
Views: 1731
Reputation: 19
  worked for me
<html>
<body>
<form method="post" action="test.php">
<input type="text" name="  TEST  " value=" TEST "/>
<input type="submit" />
</form>
</body>
  - Single space, for more spaces use more
Upvotes: 0
Reputation: 26
Why would you want your input name to contain all those spaces? Might there be a better solution to what you're trying to achieve, perhaps?
Upvotes: 0
Reputation: 2350
They were dropped, you can't. According to HTML 4 spec: 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 (".").
The working draft for HTML 5 is even more permissive, saying only that an id must contain at least one character and may not contain any space characters. See: What are valid values for the id attribute in HTML?
Upvotes: 3