Any Best way to create PHP Form Validation submission form without js?

Hello I am a newbie of PHP Any Best way to create PHP Form Validation submission form without js??

My html code:

Hello I am a newbie of PHP
Any Best way to create PHP Form Validation submission form without js??

My html code:

<form method="post" action="<?php echo htmlspecialchars($_SERVER("PHP_SELF"));?>">  
  Name: <input type="text" name="name" value="<?php echo $name;?>">
  <span class="error">* <?php echo $nameErr;?></span>
  <br><br>
  E-mail: <input type="text" name="email" value="<?php echo $email;?>">
  <span class="error">* <?php echo $emailErr;?></span>
  <br><br>
  <input type="submit" name="submit" value="Submit">  
</form>

My PHP Form Validation code:

    $nameErr = $emailErr = $subjectErr = $methodErr = $messageErr = "";
    $name = $email = $ccemail = $subject = $method = $message = "";
    $nameis_good = false; // check Name is fix the requirement  
    $emailis_good = false; // check Email is fix the requirement  
    
    
    if ($_SERVER("REQUEST_METHOD") == "POST") {
      if (empty($_POST("name")) && !strlen($_POST("name"))) {
        $nameErr = "Name is required";
        $nameis_good = false;  
      } else {
        $name = test_input($_POST("name"));
        $nameis_good = true;   
      }
      
      if (empty($_POST("email")) && !strlen($_POST("email"))) {
        $emailErr = "Email is required";
        $emailis_good = false;   
      } else {
        $email = test_input($_POST("email"));
        $emailis_good = true;   
        // check if e-mail address is well-formed
        if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
          $emailErr = "Invalid email format";
          $emailis_good = false;   
        }
    }
    //If the form is fit for requirment
    if($nameis_good && $emailis_good){
       // Upload to db script
    }
}

It is my way to create PHP Form Validation submission form without js??

Is it the best way??

any suggestions would be appreciated? Thank you very much