Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 977709
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T03:56:39+00:00 2026-05-16T03:56:39+00:00

I have an HTML form POSTing to the following index.php: <?php require_once(/home/full/path/to/included/file.php); ?> And

  • 0

I have an HTML form POSTing to the following index.php:

<?php require_once("/home/full/path/to/included/file.php"); ?>

And in file.php, I am trying to access $_POST:

ob_start();
session_start();
var_dump($_POST);
$contents = ob_get_contents();
ob_end_clean();
echo $contents;

But var_dump($_POST) returns an empty array.

Moving the ob functions to the index.php has no effect.

If I put the var_dump($_POST) before ob_start(), OR if I remove the output buffering altogether, the problem disappears, but I need output buffering. So in an effort to hunt down the problem, I tried POSTing the form data to a test.php:

ob_start();
$session_start;
var_dump($_POST);
$contents = ob_get_contents();
ob_end_clean();
echo $contents;

And it displayed everything fine. So the problem with my file.php seems to be that it is both included, and using output buffering. Do you see a problem with my setup? Why can’t $_POST be accessed by an included, output-buffered script? Do you see a way to fix this, or an alternative? Thanks.

EDIT:
One other possible factor:
My HTML form tag is this:

<form action="/" method="POST">

I use mod_rewrite to redirect that to index.php. I try action=”/index.php” and nothing changes, so it shouldn’t matter.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T03:56:40+00:00Added an answer on May 16, 2026 at 3:56 am

    I realized the cause of my problem. Having removed output buffering, I took a closer look at the error messages and realized I had a header(“Location: …”) call in my file.php. I was redirecting to another script in which I was attempting to call the $_POST information. But $_POST information obviously doesn’t get transferred along with a header() redirect.

    The interesting thing about this is that I had a var_dump($_POST) before the header() call. And I’m guessing the output buffering caused the header() call to be sent first, and therefore no output after that in the buffer was displayed, because a header(“Location”) redirects without displaying any script output after it. Does that sound right?

    (Answering my own question a la https://meta.stackexchange.com/questions/12513/should-i-not-answer-my-own-questions )

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have successfully setup an HTML form in PHP File #1, and it is
hie i have a html form and while posting a request to a url
I have an HTML form - with PHP, I am sending the data of
I have a html form for uploading a file, which is as follows: $uploadhtml
Hello i have an html form and i'm posting data but i'm unable to
I have created a form (enquiry form) in HTML that posts to the following
I have a Html form. I want to get the file containing posted form's
I have a HTML form, and I have a Controller Action that accepts the
I have an HTML form generated by JSF which maps an input element to
I have a HTML form containing checkboxes in the form of .. <input type=checkbox

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.