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

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

    if (empty($_POST["myname"])) {
      $errors["name"] = "Specify the name.";
    }
    if (empty($_POST["myemail"])) {
      $errors["email"] = "Specify the email.";
    }
  }
?>
<!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"></div>
      <?php
        if ($errors["name"] != "") {
          echo "<div class=\"errors\">".$errors["name"]."</div>";
        }
      ?>
      <div><input type="email" name="myemail"></div>
      <?php
        if ($errors["email"] != "") {
          echo "<div class=\"errors\">".$errors["email"]."</div>";
        }
      ?>
      <div><input type="submit" name="submit"></div>
    </form>
  </section>
  <?php
    if (isset($_POST["submit"]) && !array_filter($errors)) {
      echo "<p>Values received.</p>";
    }
  ?>
</body>
</html>