Page 1 of 1

PHP Post Variables are empty

Posted: Fri Apr 03, 2009 1:38 pm
by arunkumarm
Hi Everyone,

Issue: PHP Post variables are empty after submit.

Details:
<?php
include("function.php");
echo $_POST['id1'];
echo $id1;
fnc1();
?>
function.php:
function fnc1() {
ID1=<?=$_POST['id1'];?>
<form method="post">
<input type="hidden" name="id1" value="login" />
<input type="submit" />
</form>
}

Steps taken to fix this issue (although unsuccessful)

A. 1. wrote the below code snippet to get php config: (Thanks to developers like you that posted in some forum)

<?php
phpinfo();
?>

2. register_globals is off

3. Both the variables _POST['variableName'] and $variableName seem to be empty.

B. Tried copying php.ini to public_html folder.

Additional Information: GET variables work and POST variables are empty.

Please advise.

Re: PHP Post Variables are empty

Posted: Fri Apr 03, 2009 2:22 pm
by php_east
turn on error reporting at the top, error_reporting(E_ALL);
and your form goes nowhere.

Re: PHP Post Variables are empty

Posted: Fri Apr 03, 2009 3:35 pm
by Reviresco

Code: Select all

<?php
include("function.php");
fnc1();
echo $_POST['id1'];
echo $id1;
?>

Code: Select all

<?php
function fnc1() {
$id1 = $_POST['id1'];
return $id1;
}
?>

Re: PHP Post Variables are empty

Posted: Fri Apr 03, 2009 4:50 pm
by arunkumarm
Hey Guys...
Thank you very much for all the responses.

After setting error_reporting to all:

"Undefined index: id1 in function.php"

php_east - I thought i was including this file in original file so action wasnt required.

McInfo - isset is always returning false.

Im still confused.

Re: PHP Post Variables are empty

Posted: Fri Apr 03, 2009 7:09 pm
by becky-atlanta
If you want to result to output to the same form, you need this action:

Code: Select all

action="<?php $PHP_SELF ?>"

Re: PHP Post Variables are empty

Posted: Sun Apr 05, 2009 8:14 am
by Reviresco
Let's see the form -- sounds like id1 is missing.
arunkumarm wrote:Hey Guys...
Thank you very much for all the responses.

After setting error_reporting to all:

"Undefined index: id1 in function.php"

php_east - I thought i was including this file in original file so action wasnt required.

McInfo - isset is always returning false.

Im still confused.