Jump to content

POST Variable with spaces in it


Jezza

Recommended Posts

<input type=hidden name="My Value" value="lol">

 

Later on...

 

echo $_POST["My Value"];

 

The result is nothing, why doesn't this work and what can i do to get around this. It only does this when my POST variable doesn't have a space and i would LARGELY prefer this thing to be possible, how can i do this? Thanks for the help.

Link to comment
https://forums.phpfreaks.com/topic/188552-post-variable-with-spaces-in-it/
Share on other sites

Why do you need a space in the first place?  Typically though, there shouldn't be a problem with spaces.  But professionally, spaces are a no-no.

 

 

Some questions to look over

--------------------------------------------------------------

Are you sure you're form's method is set to POST?

Are you sure you are POSTing to the correct page?

I have a foreach() way of drawing a form for putting it in a database just say:

 

$form=Array("Name");

 

it will display

 

$val:

 

and whatnot

This doesn't make much sense.

 

You'll have to show more code than that if you want some quality help.

PHP will convert spaces and dots (and certain other characters) with underscore for $_POST and family (I believe the reasoning is to make a valid variable name).  Either be aware of this automated conversion and code your receiving script with it in mind, or make sure the variable name is 'valid' (in the sense that it won't get changed) in the form.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.