Jump to content

form problem


edg322

Recommended Posts

When I submit my form, a blank page is returned back with no content.  The form should post back to itself.  (The 'action' attribute is the same page)

I have the following code at the top of the page:

[tt]if(isset($_POST['postback']) && $_POST['postback']=='y' ){
echo "page posted back";}
else {
echo "page did not post back";
}[/tt]

And within my form I have:

[tt]<input type="hidden" name="postback" value="y">[/tt]

When I first load the page, "page did not post back" is found on the top of the page.

However when I submit the form, no content is returned at all.  Any suggestions?  ???
Link to comment
https://forums.phpfreaks.com/topic/24349-form-problem/
Share on other sites

Your snippet looks fine to me.
If you are doing this just to determine wether a form is posted or not in general, you could sniff for the submit button instead - saving you the trouble of hidden fields:
[code]

<?php

if(isset($_POST['submit']))
{
  echo "Form is posted";
}

echo <<<_HTML

<form method="post" action="test.php">
<input type="text" name="q" />
<input type="submit" name="submit" value="Post this form" />
</form>

_HTML;

?>

[/code]
Link to comment
https://forums.phpfreaks.com/topic/24349-form-problem/#findComment-110780
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.