Page 1 of 1

$_post

Posted: Mon Jan 05, 2009 12:27 pm
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?

Re: $_post

Posted: Mon Jan 05, 2009 12:47 pm
by andyhoneycutt
php is case sensitive. I believe you need to reference it as $_POST

-Andy

Re: $_post

Posted: Mon Jan 05, 2009 3:11 pm
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']

Re: $_post

Posted: Mon Jan 05, 2009 3:24 pm
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

Re: $_post

Posted: Mon Jan 05, 2009 4:01 pm
by Reviresco
It has to be $_POST

Uppercase, but space allowed.

Re: $_post

Posted: Mon Jan 05, 2009 4:05 pm
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

Re: $_post

Posted: Mon Jan 05, 2009 4:08 pm
by Reviresco
Yes, mine too. It only doesn't work if POST isn't all uppercase.

Re: $_post

Posted: Mon Jan 05, 2009 4:08 pm
by andyhoneycutt
oh, i totally read that wrong. my bad. what Reviresco said. :oops:

Re: $_post

Posted: Mon Jan 05, 2009 4:20 pm
by Syntac
Oh, and remember to use semicolons. :roll:

Re: $_post

Posted: Mon Jan 05, 2009 4:23 pm
by andyhoneycutt
Syntac wrote:Oh, and remember to use semicolons. :roll:
lol wicked

Re: $_post

Posted: Tue Jan 06, 2009 5:27 pm
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...