Search
 
SCRIPT & CODE EXAMPLE
 

PHP

PHP Forms - Required Fields

<?php
// define variables and set to empty values
$nameErr = $emailErr = $genderErr = $websiteErr = "";
$name = $email = $gender = $comment = $website = "";

if ($_SERVER["REQUEST_METHOD"] == "POST") {
  if (empty($_POST["name"])) {
    $nameErr = "Name is required";
  } else {
    $name = test_input($_POST["name"]);
  }

  if (empty($_POST["email"])) {
    $emailErr = "Email is required";
  } else {
    $email = test_input($_POST["email"]);
  }

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

  if (empty($_POST["comment"])) {
    $comment = "";
  } else {
    $comment = test_input($_POST["comment"]);
  }

  if (empty($_POST["gender"])) {
    $genderErr = "Gender is required";
  } else {
    $gender = test_input($_POST["gender"]);
  }
}
?>
Comment

PREVIOUS NEXT
Code Example
Php :: json_encode() in php 
Php :: convert any phone number in us number format php 
Php :: print only some characters of a string in php 
Php :: redrectnh to https n laravel 
Php :: php find first occurrence in string 
Php :: laravel request except multiple 
Php :: Create a laravel project with any version 
Php :: laravel make component inline 
Php :: php check if entire array are in another array 
Php :: random string in php 
Php :: tinyinteger laravel +size 
Php :: array associativo php 
Php :: brew install php 5.6 
Php :: replace in php 
Php :: subdomain in laravel and xampp 
Php :: laravel assets path 
Php :: laravel run specific feature test 
Php :: laravel route only and except 
Php :: laravel tree category 
Php :: array_key_exists 
Php :: You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file laravel 
Php :: php take picture with mobile camera 
Php :: laravel validate datetime with datetime-local 
Php :: php array check 
Php :: calculate total time from start and end datetime in php 
Php :: laravel eloquent soft delete 
Php :: wordpress Warning: Cannot modify header information - headers already sent by 
Php :: how to remove keys in subarray php 
Php :: php encrypt decrypt url parameters 
Php :: Redirect to external domain in Laravel 
ADD CONTENT
Topic
Content
Source link
Name
8+5 =