...

View Full Version : Resolved $_Post "Empty" on form Submit



lizsatoshi
11-15-2011, 05:59 PM
Alright, this was working last week, and I come into the office yesterday and all of my forms no longer work.

Checking print_r($_POST) , var_dump($_POST), etc. they all return blank.

Firebug shows the posted values.

Yesterday I get it to work once after clearing all Temporary Internet Files from IE, but even continuing to do that each time, it no longer works.

Does anyone have any idea why this would suddenly stop working, and what I could do to fix it?

(Using $_GET instead is not really an option here, but in testing $_GET does work just fine.)

amof
11-15-2011, 06:05 PM
can you post your code and markup?

lizsatoshi
11-15-2011, 06:16 PM
This is an extremely scaled down version of my code, but it is still not working.

<HTML>
<body>
<?php
print_r($_POST);

var_dump($_POST);

if(isset($_POST['Submit'])) {
echo "yes";

}
?>
<form name="form1" method="post" action="<? echo$_SERVER['PHP_SELF'] ?>">
Location Name:<input name="locationname" type="text" id="locationname"size="25">
<input type="submit" name="Submit" value="Submit">
<input type="reset" name="Submit2" value="Reset">
</form>

</body>
</HTML>

amof
11-15-2011, 06:24 PM
I think your problem lies with your form action.
Try to get into the habit of declaring your php tags with <?php

Try this:


<HTML>
<body>
<?php
print_r($_POST);

var_dump($_POST);

if(isset($_POST['Submit'])) {
echo "yes";
}
?>

<form name="form1" method="post" action="<?php echo $_SERVER['PHP_SELF'] ?>">
Location Name:<input name="locationname" type="text" id="locationname"size="25">
<input type="submit" name="Submit" value="Submit">
<input type="reset" name="Submit2" value="Reset">
</form>

</body>
</HTML>

lizsatoshi
11-15-2011, 06:26 PM
I appreciate the thought, but as i said, this code was working as before. I did add the <?php but no change.

lizsatoshi
11-15-2011, 06:30 PM
I do not believe it to be a problem with my code. Espicially since Firebug catches the $_POST. Maybe a server issue? I haven't touched the conf file since I installed the thing weeks ago. The only thing that has changed on the system would be Windows Updates. Could that cause a problem like this?

Ahlahn
11-16-2011, 02:57 PM
You're missing a semicolon after echo in your action attribute.

lizsatoshi
11-16-2011, 05:53 PM
Thank you. Doesn't make a difference. As I said, not a problem with the code. Guess I will try a different forum.

Fou-Lu
11-16-2011, 06:34 PM
Open the output source code in your browser.
Does the PHP code show in there?


BTW, in PHP $_POST is NEVER empty. Its a superglobal thats defined by default, so even when using a program directly on the cli you will end up with the results of Array(). This is why my assumption is you can view the PHP code within your HTML source.

lizsatoshi
11-16-2011, 08:17 PM
Open the output source code in your browser.
Does the PHP code show in there?

BTW, in PHP $_POST is NEVER empty. Its a superglobal thats defined by default, so even when using a program directly on the cli you will end up with the results of Array(). This is why my assumption is you can view the PHP code within your HTML source.


No it does not show. The ARRAY is empty is what I should have said. ;)

On the bright side, I figured it out.

I was navigating from a page that used NTLM Authentication so because of blahblahblahsecurity reason i dont understandblahblahblah the $_POST was empty. This was my fault, I just had not added the same function to all my pages yet.

The reason it would work sometimes in other browsers was because I would go to the form's page directly from the address bar, instead of going through the homepage(the page with the NTLM).

Hope this helps anyone else having a similar problem. (Though it probably won't as I don't really know WHY NTLM hates me so much. :p)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum