Code has been added to clipboard!

PHP Required Field

Example
<?php
  $fullname_error = $email_error = $gender_error = $website_error = "";
  $fullname = $email = $gender = $feedback = $website = "";

  if ($_SERVER["REQUEST_METHOD"] == "POST") {
    if (empty($_POST["fullname"])) {
      $fullname_error = "Required";
    } else {
      $fullname = proc_input($_POST["fullname"]);
    }

    if (empty($_POST["email"])) {
      $email_error = "Required";
    } else {
      $email = proc_input($_POST["email"]);
    }

    if (empty($_POST["website"])) {
      $website = "";
    } else {
      $website = proc_input($_POST["website"]);
    }

    if (empty($_POST["feedback"])) {
      $feedback = "";
    } else {
      $feedback = proc_input($_POST["feedback"]);
    }

    if (empty($_POST["gender"])) {
      $gender_error = "Required";
    } else {
      $gender = proc_input($_POST["gender"]);
    }
  }
?>