表单不会重定向到响应页面

Created a form, and it checks for errors with php, but after a successful submission it doesn't redirect to the response page I created (thanks.php). It redirects to the same contact page with the same header and page format, but no actual text and the bodytext div doesn't show up. I just need it to redirect to the response page that I created. Any help?

Here's the code:

<?php
 $firstnameerror=$browsererror=$sexerror=$dateerror=$visiterror=$judgementerror=$emailerror=$emailconfirmerror="";

 if (isset($_GET['submit'])){
        $browser = htmlspecialchars($_GET['browser']);
        $firstname = htmlspecialchars($_GET['firstname']);
        $lastname = htmlspecialchars($_GET['lastname']);
        $sex = htmlspecialchars($_GET['sex']);
        $date = htmlspecialchars($_GET['date']);
        $visit = htmlspecialchars($_GET['visit']);
        $judgement = htmlspecialchars($_GET['judgement']);
        $message = htmlspecialchars($_GET['message']);
        $email = htmlspecialchars($_GET['email']);
        $emailconfirm = htmlspecialchars($_GET['emailconfirm']);

        echo "<p>form submitted</p>";

        if (isset($browser) && isset($firstname) && isset($lastname) && isset($sex) && isset($date) && isset($visit)
          && isset($judgement) && isset($message) && isset($email) && isset($emailconfirm)){
            echo "<p>all fields were submitted</p>";}

        if (empty($firstname)){
            $firstnameerror .= "<div class= 'error'>First name is missing</div>";}

        if (empty($browser)){
            $browsererror .= "<div class= 'error'>Tell us where you're from</div>";}

        if (empty($sex)){
            $sexerror .= "<div class= 'error'>Gender is missing</div>";}

        if (empty($date)){
            $dateerror .= "<div class= 'error'>Date is missing</div>";}

        if (empty($visit)){
            $visiterror .= "<div class= 'error'>Tell us what you visited</div>";}

        if (empty($judgement)){
            $judgementerror .= "<div class= 'error'>Tell us what you thought</div>";}

        if (!empty($email) && empty($emailconfirm)){
            $emailerror .= "<div class= 'error'>Please confirm your email</div>";}

        if ($email != $emailconfirm){
            $emailconfirmerror .= "<div class='error'>Make sure your emails match.</div>";}

      if (empty($browsererror) && empty($firstnameerror) && empty($sexerror) && empty($dateerror) && empty($visiterror) && empty($judgementerror) && empty($emailerror)
          && empty($emailconfirmerror)){
          header('Location: thanks.php');
          exit();
        }
      }
?>

 <div class="bodytext">
  <form method="get" action="contact.php">
    <h2>Feedback</h2>
    <fieldset>
    <div>
    <label for="browser">Who are you?</label> <span style="font-size:10px;color:red">*Required</span><br>
    <input list="browsers" name="browser" placeholder="Click Arrow ->">
    <datalist id="browsers">
      <option value="Visitor">
        <option value="Town Resident">
          <option value="Cornell University Student">
            <option value="Ithaca College Student">
              <option value="Cornell University Professor">
                <option value="Ithaca College Professor">
                </datalist><?php echo $browsererror ?>
                </div><br><br>
                <div>
                <label for="firstname">First name</label> <span style="font-size:10px;color:red">*Required</span><br>
                <input type="text" name="firstname" placeholder="First Name" value="<?php echo $firstname ?>"/><br>
                <?php echo $firstnameerror ?>
              </div>
              <div>
                <label for="lastname">Last name</label><br><input type="text" name="lastname" placeholder="Last Name" value="<?php echo $lastname ?>"/>
              </div><br><br>
              <div>
                <label for="gender">Gender:</label>
                <input type="radio" name="sex" value="Male" checked>Male
                <input type="radio" name="sex" value="Female">Female<br>
                <?php echo $sexerror ?>
              </div><br>
              <div>
                <label for="date">Date of Visit</label> <span style="font-size:10px;color:red">*Required</span><br>
                <input type="date" name="date" min="2014-10-03" max="2014-10-05"><br>
                <?php echo $dateerror ?>
              </div><br>
              <div>
                <label for="visit">What did you visit?</label> <span style="font-size:10px;color:red">*Required</span><br>
                <input type="checkbox" name="visit" value="Fairway Market" checked>Fairway Market<br>
                <input type="checkbox" name="visit" value="Car Show">Car Show<br>
                <input type="checkbox" name="visit" value="First Peoples' Festival">First Peoples' Festival<br>
                <input type="checkbox" name="visit" value="Concerts">Concerts<br>
                <input type="checkbox" name="visit" value="Finger Lakes Cider Week">Finger Lakes Cider Week<br>
                <input type="checkbox" name="visit" value="Apple Pie Bake-off">Apple Pie Bake-off<br>
                <input type="checkbox" name="visit" value="Gallery Night">Gallery Night<br>
                <input type="checkbox" name="visit" value="Other">Other<br>
                <?php echo $visiterror ?>
              </div><br>
              <div>
                <label for="judgement">What did you think?</label> <span style="font-size:10px;color:red">*Required</span><br>
                <input type="radio" name="judgement" value="Loved It" checked>Loved It<br>
                <input type="radio" name="judgement" value="Liked It">Liked It<br>
                <input type="radio" name="judgement" value="Neutral">No Opinion/Neutral<br>
                <input type="radio" name="judgement" value="Didn't Like It">Didn't Like It<br>
                <input type="radio" name="judgement" value="Hated It">Hated It<br>
                <?php echo $judgementerror ?>
              </div><br>
              <div>
                <label for="message">Suggestions/Improvements</label><br>
                <textarea name="message" id="message" placeholder="Type your message here" value="<?php echo $message ?>"/></textarea><br><br>
               </div>
               <div>
                Do you want to be contacted about<br>future Downtown Ithaca Events?<br>
                <label for="email">E-mail:</label>
                <input type="email" name="email" placeholder="Type E-mail" value="<?php echo $email ?>"/><br>
                <label for="emailconfirm">Confirm:</label>
                <input type="email" name="emailconfirm" id="emailconfirm" placeholder="Confirm E-mail" value="<?php echo $emailconfirm ?>"/><br><br>
                <?php echo $emailerror ?><?php echo $emailconfirmerror ?></div>
                <input name="ResponseForm" type="hidden" value="thanks.php"/>
                <button type="submit" name="submit">Submit</button>
                </fieldset>
              </form>
          </div>
          <script src="JS/myscript.js"></script>
        </body>
        </html>

You can't redirect after echoing content. Remove this echo and it will redirect:

echo "<p>form submitted</p>";

You can't use header("location: somewhere.php"); after any output, it doesn't matter if is a space or just H or Hi, you just can't use it.

You have to handle the form data before show any data. Also, you should validate with JS, because of this way you don't have to make an innecesarias request to the server and help the server to receive adequate data and remember, don't output anything before call header("location: somewhere.php");

empty only triggers if a variable does not exist or is set to false. If you create a variable with no value, empty will not trigger.

So, change your conditional statements from:

empty($browsererror)

To:

!$browsererror