PHP表单重置按钮 - 使用method =“get”清除会话

I have created a multipage form that is storing the data in sessions. Instead of using method="post" I am using method="get" to allow the user to click the back button and hold the data on previous pages to edit. I also have email validation happening in the PHP script.

How would I be able to have a submit button advance to the next page in the form and a Reset button to clear the session and stay on this page (or reload the page) without the session data appearing within the form fields?

I have tried modifying someone else's suggestion using the following without success. Here is the PHP script at the start of the document:

<?php
session_start();
foreach ( $_GET as $key=>$value ) {
  if ( $key!="submit" ) {
      $value = htmlentities(stripslashes(strip_tags($value)));
      $_SESSION[$key] = $value;
  } 
}

$firstname = $_SESSION['Firstname'];
$lastname = $_SESSION['Lastname'];
$email = $_SESSION['Email'];

if(isset($_GET['clear'])) {
  session_destroy(); // Or other session-unsetting logic
  header("Location: form.php"); // Reload your page
}

else if(isset($_GET['submit'])) {
//next page logic
header("Location: form-2.php"); // Reload your page
}
?>

Here is the form within the page body:

<form class="mod-columns-form" method="get" name="mailform" action="form-2.php" onsubmit="return validateForm();">
 <fieldset>
  <label for="Firstname">First Name <span class="mod-error">*</span></label>
  <input type="text" name="Firstname" id="Firstname" placeholder="first name" value="<? echo $firstname; ?>" />
  <label for="Lastname">Last Name <span class="mod-error">*</span></label>
  <input type="text" name="Lastname" id="Lastname" placeholder="last name" value="<? echo $lastname; ?>" />
  <label for="Email">Email <span class="mod-error">*</span></label>
  <input type="text" name="Email" id="Email" placeholder="yourname@domain.com" value="<? echo $email; ?>" />
  <button name="submit" type="submit" value="submit" class="submit">Next</button>
  <button name="clear" type="submit" value="clear">Clear</button>
 </fieldset>
</form>

to free you from the data in the form , you can create a button , which perform reset the variables.

<button name="reset" value="resert">RESET</button>

you need to check the session this page, creating a small code block in php .

<?php           
session_start();
if (!isset($_SESSION['Firstname']) && $_SESSION['Lastname'] && $_SESSION['Email']) 
{
    print "error";
}
?>