$_post

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Sephern
Forum Commoner
Posts: 73
Joined: Sun Jan 04, 2009 4:44 pm

$_post

Post by Sephern »

I can't seem to get anything with $_post to work.
An example of the code I've been writing would be

Code: Select all

 
<form action ="test.php" method="post"> 
  <input type="text" name="result" />
<input type="submit" />
</form>
as a html document.

And then test.php

Code: Select all

$test = $_post ['result']
 
echo $test

Whenever I put this in htdocs, and run it on localhost, I can type in, and submit the form, and it takes me to the test.php page. The problem is that the page returns blank, with no text at all in.

If I set normal variables inside the php, and then echo it like this-

Code: Select all

$test = "test"
echo $test
Then it will return with the variable value (in this case 'test'). But if I use $_post it doesn't work.

What am I doing wrong?
User avatar
andyhoneycutt
Forum Contributor
Posts: 468
Joined: Wed Aug 27, 2008 10:02 am
Location: Idaho Falls

Re: $_post

Post by andyhoneycutt »

php is case sensitive. I believe you need to reference it as $_POST

-Andy
LiveFree
Forum Contributor
Posts: 258
Joined: Tue Dec 06, 2005 5:34 pm
Location: W-Town

Re: $_post

Post by LiveFree »

In addition to the previous post's advice, there cannot be a space between $_POST and the ['result']
They must be together, like $_POST['result']
User avatar
andyhoneycutt
Forum Contributor
Posts: 468
Joined: Wed Aug 27, 2008 10:02 am
Location: Idaho Falls

Re: $_post

Post by andyhoneycutt »

There is nothing illegal about "$_POST ['abc']". I would say depending on your formatting it may be easier to read your code with the extra space in there, but it raises no objections from the compiler.

-Andy
Reviresco
Forum Contributor
Posts: 172
Joined: Tue Feb 19, 2008 4:18 pm
Location: Milwaukee

Re: $_post

Post by Reviresco »

It has to be $_POST

Uppercase, but space allowed.
User avatar
andyhoneycutt
Forum Contributor
Posts: 468
Joined: Wed Aug 27, 2008 10:02 am
Location: Idaho Falls

Re: $_post

Post by andyhoneycutt »

I am receiving the same output of $_POST either way I perform the echo:

Code: Select all

echo $_POST['item'];
gives the exact same output as

Code: Select all

echo $_POST ['item'];
at least it does on my server...

-Andy
Reviresco
Forum Contributor
Posts: 172
Joined: Tue Feb 19, 2008 4:18 pm
Location: Milwaukee

Re: $_post

Post by Reviresco »

Yes, mine too. It only doesn't work if POST isn't all uppercase.
User avatar
andyhoneycutt
Forum Contributor
Posts: 468
Joined: Wed Aug 27, 2008 10:02 am
Location: Idaho Falls

Re: $_post

Post by andyhoneycutt »

oh, i totally read that wrong. my bad. what Reviresco said. :oops:
User avatar
Syntac
Forum Contributor
Posts: 327
Joined: Sun Sep 14, 2008 7:59 pm

Re: $_post

Post by Syntac »

Oh, and remember to use semicolons. :roll:
User avatar
andyhoneycutt
Forum Contributor
Posts: 468
Joined: Wed Aug 27, 2008 10:02 am
Location: Idaho Falls

Re: $_post

Post by andyhoneycutt »

Syntac wrote:Oh, and remember to use semicolons. :roll:
lol wicked
Sephern
Forum Commoner
Posts: 73
Joined: Sun Jan 04, 2009 4:44 pm

Re: $_post

Post by Sephern »

=D thanks for all the help.

I'm kinda new to PHP, and thought that $_POST would be a good place to start learning, after I'd got the echo and variable basics...
Post Reply