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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.