PHP Post Variables are empty

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
arunkumarm
Forum Newbie
Posts: 2
Joined: Fri Apr 03, 2009 1:22 pm

PHP Post Variables are empty

Post 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.
User avatar
php_east
Forum Contributor
Posts: 453
Joined: Sun Feb 22, 2009 1:31 pm
Location: Far Far East.

Re: PHP Post Variables are empty

Post by php_east »

turn on error reporting at the top, error_reporting(E_ALL);
and your form goes nowhere.
Reviresco
Forum Contributor
Posts: 172
Joined: Tue Feb 19, 2008 4:18 pm
Location: Milwaukee

Re: PHP Post Variables are empty

Post 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;
}
?>
arunkumarm
Forum Newbie
Posts: 2
Joined: Fri Apr 03, 2009 1:22 pm

Re: PHP Post Variables are empty

Post 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.
User avatar
becky-atlanta
Forum Commoner
Posts: 74
Joined: Thu Feb 26, 2009 6:26 pm
Location: Atlanta, GA

Re: PHP Post Variables are empty

Post 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 ?>"
Reviresco
Forum Contributor
Posts: 172
Joined: Tue Feb 19, 2008 4:18 pm
Location: Milwaukee

Re: PHP Post Variables are empty

Post 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.
Post Reply