Web Hosting Talk







View Full Version : PHP $HTTP_POST_VARS question


dhui
08-09-2008, 08:10 PM
Ok this is pretty basic...and I have done this alot but for some reason it isn't working for me now. Here is a simple example of what I am trying to do.

------------test.php-------------
<form name="formtest" method="post" action="doTest.php">
<input type="text" size="50" name="test" />
<input type="submit" name="submit" value="submit" />
</form>

------------doTest.php-----------
<?php
$test = $HTTP_POST_VARS["test"];

echo $test;
?>

I am just trying a simple post vars test getting input from the user with a simple form entry and echoing it out in the "doTest.php". Should work....but for some reason I keep getting blanks in "$HTTP_POST_VARS["test"]". Anyone got an idea on what's wrong? code problem or server problem?

Adam-AEC
08-09-2008, 09:12 PM
Why $HTTP_POST_VARS and not $_POST?

I think HTTP_POST_VARS is depreciated.

CodyRo
08-09-2008, 09:20 PM
Why $HTTP_POST_VARS and not $_POST?

I think HTTP_POST_VARS is depreciated.

Bingo.. use either $_POST, $_GET, or $_REQUEST :)

zacharooni
08-09-2008, 09:43 PM
Just remember to wash your variables before you eat them. Or something to that effect. :)

dhui
08-10-2008, 12:43 AM
ok...it might be depreciated but it should still work...in either case, I used $_POST["test"];......and it still doesn't work. When I echo back $test, it still shows up with nothing.

Adam-AEC
08-10-2008, 12:58 AM
Sounds like a server problem.

Try using print_r on your $_POST variable and see if there is anything in it.

What version of PHP?

bigfan
08-10-2008, 07:21 PM
And $HTTP_POST_VARS is deprecated, not depreciated.

Adam-AEC
08-10-2008, 07:25 PM
And $HTTP_POST_VARS is deprecated, not depreciated.

Phew, and I thought the grammar police took Sunday's off. That's a load off my mind!

How about the problem at hand? Any insight, oh wise one?

larwilliams
08-10-2008, 07:34 PM
Try this:

test.php


<form action="doTest.php" method="post" enctype="multipart/form-data" name="formtest" id="formtest">
<input type="text" size="50" name="test" />
<input type="submit" name="submit" value="submit" />
</form>


doTest.php

<?php
$test = $_POST["test"];
echo $test;
?>

bigfan
08-10-2008, 08:44 PM
It's not grammar, and of course you're free to continue saying "depreciated".
Any insight, oh wise one?Yeah, but it would rile you even more.

JBapt
08-15-2008, 02:17 PM
Please learn to sanitize the inputs! NEVER EVER trust a form input. Learn to program properly!