<?php
  $errors = ["name"=>"", "email"=>""];
  $name = $email = "";

  if (isset($_POST["submit"])) {
    $name = $_POST["myname"];
    $email = $_POST["myemail"];

    if (!preg_match("/^[a-zA-Z]+$/", $name)) {
      $errors["name"] = "Specify a valid name.";
    }
    if (!filter_input(INPUT_POST, "myemail", FILTER_VALIDATE_EMAIL)) {
      $errors["email"] = "Specify a valid email.";
    }
  }
  if (isset($_POST["submit"]) && !array_filter($errors)) {
    header("Location: account.php?name=".$name."&email=".$email);
    exit();
  }
?>
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>PHP Document</title>
  <style>
    .errors {
      color: #990000;
    }
    div {
      padding: 5px 0px;
    }
  </style>
</head>
<body>
  <section>
    <form name="myform" method="post" action="index.php">
      <div>
        <input type="text" name="myname" value="<?php echo htmlspecialchars($name);?>">
      </div>
      <?php
        if ($errors["name"] != "") {
          echo "<div class=\"errors\">".$errors["name"]."</div>";
        }
      ?>
      <div>
        <input type="email" name="myemail" value="<?php echo htmlspecialchars($email);?>">
      </div>
      <?php
        if ($errors["email"] != "") {
          echo "<div class=\"errors\">".$errors["email"]."</div>";
        }
      ?>
      <div><input type="submit" name="submit"></div>
    </form>
  </section>
</body>
</html>