header() with if/then statements

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jerim79

    header() with if/then statements

    I have created a verification script to verify information and redirect
    the customer to the appropriate error page. For example:

    if ($FName=""){
    header('Locatio n:/verify_fname.ht m');
    }
    else{
    if ($LName=""){
    header('Locatio n:/verify_lname.ht m');
    }
    else{
    if ($Company=""){
    header('Locatio n:/verify_company. htm');
    }
    else{
    if ($Title=""){
    header('Locatio n:/verify_title.ht m');
    }
    }
    }
    }

    The intent of the code is to check a variable. If an error is found in
    the variable, it redirects to the correct error page. Otherwise, it
    continues on through the else statement which then checks another
    variable and so and so on. The final else statement redirects to a
    process script that takes all the information writes it to a table. I
    am getting this error message:
    Cannot modify header information - headers already sent by

    I can't put the redirect before the HTML as I want the redirect to be
    conditional. Any help would be appreciated.

  • Jerry Stuckle

    #2
    Re: header() with if/then statements

    Jerim79 wrote:
    I have created a verification script to verify information and redirect
    the customer to the appropriate error page. For example:
    >
    if ($FName=""){
    header('Locatio n:/verify_fname.ht m');
    }
    else{
    if ($LName=""){
    header('Locatio n:/verify_lname.ht m');
    }
    else{
    if ($Company=""){
    header('Locatio n:/verify_company. htm');
    }
    else{
    if ($Title=""){
    header('Locatio n:/verify_title.ht m');
    }
    }
    }
    }
    >
    The intent of the code is to check a variable. If an error is found in
    the variable, it redirects to the correct error page. Otherwise, it
    continues on through the else statement which then checks another
    variable and so and so on. The final else statement redirects to a
    process script that takes all the information writes it to a table. I
    am getting this error message:
    Cannot modify header information - headers already sent by
    >
    I can't put the redirect before the HTML as I want the redirect to be
    conditional. Any help would be appreciated.
    >
    Jerim,

    Why don't you want the redirect before the HTML? If you redirect the
    user, you don't want the HTML to show, do you?

    It can still be conditional. Put it at the top, and if everything is
    OK, just have it fall through to the HTML.

    BTW - this is a very user-unfriendly way of doing it. You should rather
    check all the options, then if any are incorrect, redirect with all of
    the invalid information. This way if there are three things wrong, the
    user must gets an error message for the first one and corrects it. Then
    he gets an error message for the second one, and so on.

    If you check them all, you can display all three error messages at the
    same time. Much more user friendly.

    --
    =============== ===
    Remove the "x" from my email address
    Jerry Stuckle
    JDS Computer Training Corp.
    jstucklex@attgl obal.net
    =============== ===

    Comment

    • e_matthes@hotmail.com

      #3
      Re: header() with if/then statements

      It can still be conditional. Put it at the top, and if everything is
      OK, just have it fall through to the HTML.
      >
      BTW - this is a very user-unfriendly way of doing it. You should rather
      check all the options, then if any are incorrect, redirect with all of
      the invalid information. This way if there are three things wrong, the
      user must gets an error message for the first one and corrects it. Then
      he gets an error message for the second one, and so on.
      >
      If you check them all, you can display all three error messages at the
      same time. Much more user friendly.
      Something like this, I believe:

      <?php

      // Code to check validity of data.

      if (everything valid) {
      // code to process data
      // redirect to new page
      } else {
      // Set error messages for individual data elements.
      }

      ?>

      <html>

      <form>
      <input 1>
      <?php if ($errorMsg1 != "") print $errorMsg1 ?>
      <input 2>
      <?php if ($errorMsg2 != "") print $errorMsg2 ?>
      ...

      </html>

      Comment

      • Jerim79

        #4
        Re: header() with if/then statements


        e_matthes@hotma il.com wrote:
        It can still be conditional. Put it at the top, and if everything is
        OK, just have it fall through to the HTML.

        BTW - this is a very user-unfriendly way of doing it. You should rather
        check all the options, then if any are incorrect, redirect with all of
        the invalid information. This way if there are three things wrong, the
        user must gets an error message for the first one and corrects it. Then
        he gets an error message for the second one, and so on.

        If you check them all, you can display all three error messages at the
        same time. Much more user friendly.
        >
        Something like this, I believe:
        >
        <?php
        >
        // Code to check validity of data.
        >
        if (everything valid) {
        // code to process data
        // redirect to new page
        } else {
        // Set error messages for individual data elements.
        }
        >
        ?>
        >
        <html>
        >
        <form>
        <input 1>
        <?php if ($errorMsg1 != "") print $errorMsg1 ?>
        <input 2>
        <?php if ($errorMsg2 != "") print $errorMsg2 ?>
        ...
        >
        </html>
        I appreciate the help. I think the concept is getting clearer. I am
        just curious though. The first time a person loads the webpage wouldn't
        the php execute and since all of the variables are null, wouldn't it
        automatically display an error message even before the person has had a
        chance to fill out the form?

        Comment

        • Jerry Stuckle

          #5
          Re: header() with if/then statements

          Jerim79 wrote:
          e_matthes@hotma il.com wrote:
          >
          >>>It can still be conditional. Put it at the top, and if everything is
          >>>OK, just have it fall through to the HTML.
          >>>
          >>>BTW - this is a very user-unfriendly way of doing it. You should rather
          >>>check all the options, then if any are incorrect, redirect with all of
          >>>the invalid information. This way if there are three things wrong, the
          >>>user must gets an error message for the first one and corrects it. Then
          >>>he gets an error message for the second one, and so on.
          >>>
          >>>If you check them all, you can display all three error messages at the
          >>>same time. Much more user friendly.
          >>
          >>Something like this, I believe:
          >>
          >><?php
          >>
          > // Code to check validity of data.
          >>
          > if (everything valid) {
          > // code to process data
          > // redirect to new page
          > } else {
          > // Set error messages for individual data elements.
          > }
          >>
          >>?>
          >>
          >><html>
          >>
          > <form>
          > <input 1>
          > <?php if ($errorMsg1 != "") print $errorMsg1 ?>
          > <input 2>
          > <?php if ($errorMsg2 != "") print $errorMsg2 ?>
          > ...
          >>
          >></html>
          >
          >
          I appreciate the help. I think the concept is getting clearer. I am
          just curious though. The first time a person loads the webpage wouldn't
          the php execute and since all of the variables are null, wouldn't it
          automatically display an error message even before the person has had a
          chance to fill out the form?
          >
          If you're validating on the same page, yes. You have to test for that.

          For instance, if you have your submit button as:

          <input type="submit" name="submit" value="Submit">

          you could check:

          if (isset[$_POST['submit'] && $_POST['submit'] == 'Submit') {
          ... do your validation here

          Just be sure no other page posts to this one with the same submit button.

          --
          =============== ===
          Remove the "x" from my email address
          Jerry Stuckle
          JDS Computer Training Corp.
          jstucklex@attgl obal.net
          =============== ===

          Comment

          • e_matthes@hotmail.com

            #6
            Re: header() with if/then statements

            I appreciate the help. I think the concept is getting clearer. I am
            just curious though. The first time a person loads the webpage wouldn't
            the php execute and since all of the variables are null, wouldn't it
            automatically display an error message even before the person has had a
            chance to fill out the form?
            The structure of my pages looks like this:

            <?php // Very first thing, so header redirects work

            // Initialize variables that appear in html, so they are empty, not
            null

            if ($_POST) {
            // validate & process data
            }

            ?>

            <html>
            web content
            </html>


            The if ($_POST) prevents any validation from being done until the user
            has submitted some data. It is common for many people not to bother
            initializing the variables, but if you look at your html output, it's
            pretty ugly with a bunch of "uninitiali zed variable" messages in the
            code. This all works for me locally, but I haven't gone live with it
            yet. Am I missing anything?

            Comment

            • Jerim79

              #7
              Re: header() with if/then statements


              Jerry Stuckle wrote:
              Jerim79 wrote:
              e_matthes@hotma il.com wrote:
              >>It can still be conditional. Put it at the top, and if everything is
              >>OK, just have it fall through to the HTML.
              >>
              >>BTW - this is a very user-unfriendly way of doing it. You should rather
              >>check all the options, then if any are incorrect, redirect with all of
              >>the invalid information. This way if there are three things wrong, the
              >>user must gets an error message for the first one and corrects it. Then
              >>he gets an error message for the second one, and so on.
              >>
              >>If you check them all, you can display all three error messages at the
              >>same time. Much more user friendly.
              >
              >Something like this, I believe:
              >
              ><?php
              >
              // Code to check validity of data.
              >
              if (everything valid) {
              // code to process data
              // redirect to new page
              } else {
              // Set error messages for individual data elements.
              }
              >
              >?>
              >
              ><html>
              >
              <form>
              <input 1>
              <?php if ($errorMsg1 != "") print $errorMsg1 ?>
              <input 2>
              <?php if ($errorMsg2 != "") print $errorMsg2 ?>
              ...
              >
              ></html>

              I appreciate the help. I think the concept is getting clearer. I am
              just curious though. The first time a person loads the webpage wouldn't
              the php execute and since all of the variables are null, wouldn't it
              automatically display an error message even before the person has had a
              chance to fill out the form?
              >
              If you're validating on the same page, yes. You have to test for that.
              >
              For instance, if you have your submit button as:
              >
              <input type="submit" name="submit" value="Submit">
              >
              you could check:
              >
              if (isset[$_POST['submit'] && $_POST['submit'] == 'Submit') {
              ... do your validation here
              >
              Just be sure no other page posts to this one with the same submit button.
              >
              --
              =============== ===
              Remove the "x" from my email address
              Jerry Stuckle
              JDS Computer Training Corp.
              jstucklex@attgl obal.net
              =============== ===
              Here is the basic gist of what I have:

              <?php
              $FName=$_Post['FName'];

              if ($FName !=""){
              header("Locatio n: write_to_databa se.php");
              }
              else{
              if ($FName=""){
              $errormsg1="Ple ase enter a first name":
              }
              ?>

              <html>
              <body>
              Registration
              <?php if ($errormsg1 !="") echo $errormsg1); ?>
              <br />
              <form action="(this page)" method="Post">
              First Name: <input type="text" name="FName">
              <br />
              <input type="submit" name="submit value="Submit">
              </form>
              </body>
              </html>

              Forgetting the problem about loading the errors up before filling out
              the form, I can't get this to work at all. After I click on submit it
              just brings me back to the same page, with no error messages.

              Comment

              • e_matthes@hotmail.com

                #8
                Re: header() with if/then statements

                Here is the basic gist of what I have:
                >
                <?php
                $FName=$_Post['FName'];
                >
                if ($FName !=""){
                header("Locatio n: write_to_databa se.php");
                }
                else{
                if ($FName=""){
                $errormsg1="Ple ase enter a first name":
                }
                ?>
                >
                <html>
                <body>
                Registration
                <?php if ($errormsg1 !="") echo $errormsg1); ?>
                <br />
                <form action="(this page)" method="Post">
                First Name: <input type="text" name="FName">
                <br />
                <input type="submit" name="submit value="Submit">
                </form>
                </body>
                </html>
                >
                Forgetting the problem about loading the errors up before filling out
                the form, I can't get this to work at all. After I click on submit it
                just brings me back to the same page, with no error messages.
                Try:
                <?php

                $FName = "";
                $errorMsg1 = "";

                if ($_POST) {

                if ( isset($_POST['FName']) ) {
                $FName = $_POST['FName'];
                }

                Now you can validate $FName, because it's either empty or set to
                user's value. Don't write to database without validating all data.
                The rest looks good. Good luck.

                Comment

                • Jerim79

                  #9
                  Re: header() with if/then statements


                  e_matt...@hotma il.com wrote:
                  Here is the basic gist of what I have:

                  <?php
                  $FName=$_Post['FName'];

                  if ($FName !=""){
                  header("Locatio n: write_to_databa se.php");
                  }
                  else{
                  if ($FName=""){
                  $errormsg1="Ple ase enter a first name":
                  }
                  ?>

                  <html>
                  <body>
                  Registration
                  <?php if ($errormsg1 !="") echo $errormsg1); ?>
                  <br />
                  <form action="(this page)"
                  method="Post">
                  First Name: <input type="text" name="FName">
                  <br />
                  <input type="submit" name="submit value="Submit">
                  </form>
                  </body>
                  </html>

                  Forgetting the problem about loading the errors up before filling out
                  the form, I can't get this to work at all. After I click on submit it
                  just brings me back to the same page, with no error messages.
                  >
                  Try:
                  <?php
                  >
                  $FName = "";
                  $errorMsg1 = "";
                  >
                  if ($_POST) {
                  >
                  if ( isset($_POST['FName']) ) {
                  $FName = $_POST['FName'];
                  }
                  >
                  Now you can validate $FName, because it's either empty or set to
                  user's value. Don't write to database without validating all data.
                  The rest looks good. Good luck.
                  Since I am still learning, I just wanted state the logic of the code.
                  First we set $FName equal to nothing. Then we set $errorMsg1 equal to
                  nothing. Next we say "if the method is $_POST" then check to see if
                  $_POST['FName'] has been set. If it has, then set $FName equal to
                  $_POST['FName']

                  I still can't get it to display the error message.

                  Comment

                  • Jerim79

                    #10
                    Re: header() with if/then statements


                    Jerim79 wrote:
                    e_matt...@hotma il.com wrote:
                    Here is the basic gist of what I have:
                    >
                    <?php
                    $FName=$_Post['FName'];
                    >
                    if ($FName !=""){
                    header("Locatio n: write_to_databa se.php");
                    }
                    else{
                    if ($FName=""){
                    $errormsg1="Ple ase enter a first name":
                    }
                    ?>
                    >
                    <html>
                    <body>
                    Registration
                    <?php if ($errormsg1 !="") echo $errormsg1); ?>
                    <br />
                    <form action="(this page)"
                    method="Post">
                    First Name: <input type="text" name="FName">
                    <br />
                    <input type="submit" name="submit value="Submit">
                    </form>
                    </body>
                    </html>
                    >
                    Forgetting the problem about loading the errors up before filling out
                    the form, I can't get this to work at all. After I click on submit it
                    just brings me back to the same page, with no error messages.
                    Try:
                    <?php

                    $FName = "";
                    $errorMsg1 = "";

                    if ($_POST) {

                    if ( isset($_POST['FName']) ) {
                    $FName = $_POST['FName'];
                    }

                    Now you can validate $FName, because it's either empty or set to
                    user's value. Don't write to database without validating all data.
                    The rest looks good. Good luck.
                    >
                    Since I am still learning, I just wanted state the logic of the code.
                    First we set $FName equal to nothing. Then we set $errorMsg1 equal to
                    nothing. Next we say "if the method is $_POST" then check to see if
                    $_POST['FName'] has been set. If it has, then set $FName equal to
                    $_POST['FName']
                    >
                    I still can't get it to display the error message.
                    Here is the current, non-working code:

                    <?php
                    $FName="";
                    $errormsg1="";

                    if( isset($_POST['FName']){
                    $FName=$_POST['FName'];
                    }

                    if ($FName !=""){
                    header("Locatio n: write_to_databa se.php");
                    }
                    else{
                    if ($FName=""){
                    $errormsg1="Ple ase enter a first name":
                    }
                    ?>
                    <html>
                    <body>
                    Registration
                    <?php if ($errormsg1 !=""){ echo $errormsg1; } ?>
                    <form action="new.htm " method="POST">
                    First Name: <input type="text" name="FName">
                    <br />
                    <input type="submit" name="submit" value="Submit">
                    </form>
                    </body>
                    </html>

                    Comment

                    • Pedro Graca

                      #11
                      Re: header() with if/then statements

                      Jerim79 wrote:
                      Here is the current, non-working code:
                      >
                      <?php
                      $FName="";
                      $errormsg1="";
                      >
                      if( isset($_POST['FName']){
                      $FName=$_POST['FName'];
                      }
                      >
                      if ($FName !=""){
                      header("Locatio n: write_to_databa se.php");
                      }
                      else{
                      if ($FName=""){
                      $errormsg1="Ple ase enter a first name":
                      }
                      ?>
                      <html>
                      <body>
                      Registration
                      <?php if ($errormsg1 !=""){ echo $errormsg1; } ?>
                      <form action="new.htm " method="POST">
                      First Name: <input type="text" name="FName">
                      <br />
                      <input type="submit" name="submit" value="Submit">
                      </form>
                      </body>
                      </html>
                      Here's how I'd do it:



                      <?php
                      ########
                      # initialize variables for user input and error messages
                      $FName = false;
                      $FName_error = false;
                      $LName = false;
                      $LName_error = false;
                      # initialize an error count variable
                      $error_count = 0;

                      ########
                      # Check if the page was accessed with a POST
                      if ($_SERVER['REQUEST_METHOD '] == 'POST') {
                      $FName = isset($_POST['FName']) ? $_POST['FName'] : '';
                      if (!name_is_valid ($FName)) {
                      $FName_error = 'Please enter a valid First Name.';
                      ++$error_count;
                      }
                      $LName = isset($_POST['LName']) ? $_POST['LName'] : '';
                      if (!name_is_valid ($LName)) {
                      $LName_error = 'Please enter a valid Last Name.';
                      ++$error_count;
                      }
                      if (!$error_count) {
                      ########
                      # If the script reaches here, there have been no errors detected in
                      # the user data, so we can save to the database, send mail, display
                      # a 'thank you' page, and/or redirect
                      // mysql_query("in sert ...");
                      // exit('Thank you');
                      }
                      }

                      ########
                      # When we get here after a GET $error_count will be 0 (zero).
                      # When we get here after a POST $error_count will *NOT* be 0
                      # because in the if (!$error_count) above we always exit().
                      # So
                      if ($error_count) {
                      echo 'There were errors in your submission. Please review and re-submit';
                      }

                      echo '<form action="', $_SERVER['PHP_SELF], '" method="post">' ;
                      echo 'First Name: <input type="text" value="', $FName, '">';
                      if ($FName_error) {
                      echo ' <span class="error">' , $FName_error, '</span>';
                      }
                      echo "<br>\n";

                      echo 'Last Name: <input type="text" value="', $LName, '">';
                      if ($LName_error) {
                      echo ' <span class="error">' , $LName_error, '</span>';
                      }
                      echo "<br>\n";

                      echo '<input type="submit">' ;
                      echo '</form>';
                      HTML;




                      Happy Coding :)

                      --
                      I (almost) never check the dodgeit address.
                      If you *really* need to mail me, use the address in the Reply-To
                      header with a message in *plain* *text* *without* *attachments*.

                      Comment

                      • Jerry Stuckle

                        #12
                        Re: header() with if/then statements

                        Jerim79 wrote:
                        Jerim79 wrote:
                        >
                        >>e_matt...@hot mail.com wrote:
                        >>
                        >>>>Here is the basic gist of what I have:
                        >>>>
                        >>>><?php
                        >>>>$FName=$_Po st['FName'];
                        >>>>
                        >>>>if ($FName !=""){
                        >>>>header("Loc ation: write_to_databa se.php");
                        >>>>}
                        >>>>else{
                        >>> if ($FName=""){
                        >>> $errormsg1="Ple ase enter a first name":
                        >>>>}
                        >>>>?>
                        >>>>
                        >>>><html>
                        >>>><body>
                        >>>>Registratio n
                        >>>><?php if ($errormsg1 !="") echo $errormsg1); ?>
                        >>>><br />
                        >>>><form action="(this page)"
                        >>
                        >>method="Post" >
                        >>
                        >>>>First Name: <input type="text" name="FName">
                        >>>><br />
                        >>>><input type="submit" name="submit value="Submit">
                        >>>></form>
                        >>>></body>
                        >>>></html>
                        >>>>
                        >>>>Forgettin g the problem about loading the errors up before filling out
                        >>>>the form, I can't get this to work at all. After I click on submit it
                        >>>>just brings me back to the same page, with no error messages.
                        >>>
                        >>>Try:
                        >>><?php
                        >>>
                        >> $FName = "";
                        >> $errorMsg1 = "";
                        >>>
                        >> if ($_POST) {
                        >>>
                        >> if ( isset($_POST['FName']) ) {
                        >> $FName = $_POST['FName'];
                        >> }
                        >>>
                        >> Now you can validate $FName, because it's either empty or set to
                        >>>user's value. Don't write to database without validating all data.
                        >>>The rest looks good. Good luck.
                        >>
                        >>Since I am still learning, I just wanted state the logic of the code.
                        >>First we set $FName equal to nothing. Then we set $errorMsg1 equal to
                        >>nothing. Next we say "if the method is $_POST" then check to see if
                        >>$_POST['FName'] has been set. If it has, then set $FName equal to
                        >>$_POST['FName']
                        >>
                        >>I still can't get it to display the error message.
                        >
                        >
                        Here is the current, non-working code:
                        >
                        <?php
                        $FName="";
                        $errormsg1="";
                        >
                        if( isset($_POST['FName']){
                        $FName=$_POST['FName'];
                        }
                        >
                        if ($FName !=""){
                        header("Locatio n: write_to_databa se.php");
                        }
                        else{
                        if ($FName=""){
                        $errormsg1="Ple ase enter a first name":
                        }
                        ?>
                        <html>
                        <body>
                        Registration
                        <?php if ($errormsg1 !=""){ echo $errormsg1; } ?>
                        <form action="new.htm " method="POST">
                        First Name: <input type="text" name="FName">
                        <br />
                        <input type="submit" name="submit" value="Submit">
                        </form>
                        </body>
                        </html>
                        >
                        I do things a little differently, but basically the same thing. This
                        should work. Note that the <?php MUST be the first thing in you file -
                        no whitespace or anything before it.

                        <?php

                        $errormsg1="";
                        $FName = "";
                        if (isset($_POST['submit'] && $_POST['submit'] == 'Submit') {

                        // Repeat the following for each field you wish to validate

                        if (isset($_POST['FName']))
                        $FName = trim($_POST['FName'];
                        if ($FName == "")
                        $errormsg1 = "Please enter a first name<br>\n";

                        // End of repeated code

                        if ($errormsg1 == "")
                        header("Locatio n: write_to_databa se.php");
                        }
                        ?>
                        <html>
                        <body>
                        Registration
                        <?php if ($errormsg1 !=""){ echo $errormsg1; } ?>
                        <form action="new.htm " method="POST">
                        First Name: <input type="text" name="FName" value="<?$FName ?>">
                        <br />
                        <input type="submit" name="submit" value="Submit">
                        </form>
                        </body>
                        </html>

                        The first if checks to see if the submit button was pressed.

                        The next if checks to see if FName was posted to the page. If so, it
                        trims white space before and after (in case the user entered a blank
                        space) and sets it into $FName.

                        The next if checks to see if FName is an empty string. If so, it sets
                        errormsg1.

                        You can repeat these statements to validate other fields.

                        Now - if errormsg1 is empty, it will call your write_to_databa se page
                        (more problems here - in a minute).

                        If there was an error, or the submit button was not pressed, it will
                        fall through to the rest of your code.

                        Finally, I added code to your input field to echo $FName. This will
                        fill in the field if your user has entered a first name but may be
                        missing other data. Otherwise your form will come up blank and your
                        user will have to reenter everything.

                        Now - the problem with your code. When you call the header() function
                        to transfer control, the data in $_POST is NOT sent with it. You will
                        lose all of the data that was posted to your page. Rather than
                        transferring control, you should write to the database here in this
                        page, i.e.

                        if ($errormsg1 == "") {
                        // code to connect to and write to your database
                        header('Locatio n: thankyou.html') ;
                        }

                        Where 'thankyou.html' is a page that gives them a message thanking them
                        for their input. At least I'm assuming you don't wish to return to this
                        form. If so, you can leave out the header call. And if you don't want
                        the form to show the $FName again, just set it to "" again at this
                        location.

                        --
                        =============== ===
                        Remove the "x" from my email address
                        Jerry Stuckle
                        JDS Computer Training Corp.
                        jstucklex@attgl obal.net
                        =============== ===

                        Comment

                        • Gordon Burditt

                          #13
                          Re: header() with if/then statements

                          >I have created a verification script to verify information and redirect
                          >the customer to the appropriate error page. For example:
                          >
                          >if ($FName=""){
                          >header('Locati on:/verify_fname.ht m');
                          >}
                          >else{
                          >if ($LName=""){
                          >header('Locati on:/verify_lname.ht m');
                          >}
                          > else{
                          > if ($Company=""){
                          > header('Locatio n:/verify_company. htm');
                          > }
                          > else{
                          > if ($Title=""){
                          > header('Locatio n:/verify_title.ht m');
                          > }
                          }
                          }
                          >}
                          >
                          >The intent of the code is to check a variable. If an error is found in
                          >the variable, it redirects to the correct error page. Otherwise, it
                          >continues on through the else statement which then checks another
                          >variable and so and so on. The final else statement redirects to a
                          >process script that takes all the information writes it to a table. I
                          >am getting this error message:
                          Cannot modify header information - headers already sent by
                          >
                          >I can't put the redirect before the HTML as I want the redirect to be
                          >conditional. Any help would be appreciated.
                          You MUST put the redirect before outputting any HTML, and outputting HTML
                          after the redirect is somewhat pointless, as it won't be seen.

                          Your code doesn't contain any HTML, though. Code within <?php ... ?>
                          isn't output, and won't draw that error message. However, stuff outside
                          that, like blank lines, DOCTYPE, HTML, UTF-8 markers, etc. are and
                          will mess things up.

                          Comment

                          Working...