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 7619177
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T03:37:03+00:00 2026-05-31T03:37:03+00:00

I have added some server side validation to a dropdown box on one of

  • 0

I have added some server side validation to a dropdown box on one of my pages and when I did the page wouldn’t work anymore. The code I added is as follows:

$show_form = true;        
if (isset($_POST['submit'])) {
    //All of the server side validations   
      $validator = new FormValidator();
    $validator->addValidation("hospital_name","dontselect=000","No facility was chosen");

    if ($validator->ValidateForm()) {
    // All the variables from the submission form   
    $userid = $_SESSION['user_id'];
    $hosp = $_POST['hospital_name'];
   header('Location: ../site_hospital' . $hosp . '/hospital_submitform.php?usr=' . $userid . '&&hosp=' . $hosp);
    exit;
    $show_form = false;
    } else {
    echo "<B style='color:red;'>The following errors occurred:</B>";
    $error_hash = $validator->GetErrors();
    foreach ($error_hash as $inpname => $inp_err) {
        echo "<p style='color:red;'>$inp_err</p>\n";
    }
}}        
if (true == $show_form) {

Through pure chance I added ob_start(); as part of my debugging to the beginning of the page and suddenly my code worked properly but I have no idea why and I was hoping the community could throw out an educated guess as to why. When the code stopped working it would not execute my header command above, the page would simply refresh and not change location, when I added ob_start(); to the top of the page the page redirected as planned. So the overall question is why would the page not direct using the header command without ob_start? I’m sure alot more detail and code is necessary for a definitive answer but I’m hoping someone has run into this before or has an educated guess that may lead me to my own answers. Thanks for any insight.

  • 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-31T03:37:04+00:00Added an answer on May 31, 2026 at 3:37 am

    it’s because you were writing to the output stream and preventing the header from working properly. once you started buffering other outputs, you removed the obstacle to the header’s operation.

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

Sidebar

Related Questions

I have a page with some dynamically added buttons. If you click a button
I have a page with user controls getting dynamically added. Inside some of these
I have this repeater where i have added some validation to a textbox. However,
I have added some code which compiles cleanly and have just received this Windows
I have added some dynamic textboxes upon a button click. I need the values
I have added some settings to my c# application using the configuration editor. There
In a RIA Domain service I have added some utility functions. For instance we
HI All. I have subclass of UIScrollView. IN this class I have added some
In Silverlight 3.0 I have added a custom behavior to some UIElement in Code
I have a TreeView that is bound to a XmlDataSource control. I've added some

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.