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
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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.