Search
 
SCRIPT & CODE EXAMPLE
 

PHP

PHP Form Validation

Name: <input type="text" name="name">
E-mail: <input type="text" name="email">
Website: <input type="text" name="website">
Comment: <textarea name="comment" rows="5" cols="40"></textarea>
Comment

PHP - Validation Example

<!DOCTYPE HTML>  
<html>
<head>
</head>
<body>  

<?php
// define variables and set to empty values
$name = $email = $gender = $website = "";

if ($_SERVER["REQUEST_METHOD"] == "POST") {
  $name = test_input($_POST["name"]);
  $email = test_input($_POST["email"]);
  $website = test_input($_POST["website"]);
  $gender = test_input($_POST["gender"]);
}

function test_input($data) {
  $data = trim($data);
  $data = stripslashes($data);
  $data = htmlspecialchars($data);
  return $data;
}
?>

<h2>PHP Form Validation Example</h2>
<form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>">  
  Name: <input type="text" name="name">
  <br><br>
  E-mail: <input type="text" name="email">
  <br><br>
  Website: <input type="text" name="website">
  <br><br>
  Gender:
  <input type="radio" name="gender" value="female">Female
  <input type="radio" name="gender" value="male">Male
  <input type="radio" name="gender" value="other">Other
  <br><br>
  <input type="submit" name="submit" value="Submit">  
</form>

<?php
echo "<h2>Your Input:</h2>";
echo $name;
echo "<br>";
echo $email;
echo "<br>";
echo $website;
echo "<br>";
echo $gender;
?>

</body>
</html>
Comment

PREVIOUS NEXT
Code Example
Php :: enhanced ecommerce data layer for woocommerce 
Php :: How to automail in php 
Php :: get cpanel username php 
Php :: wpdb insert or if exists update 
Php :: How to calculate age using query builder in laravel? 
Php :: Header requirements for new plugin in wordpress 
Php :: How to hide tax details from woocommerce order emails 
Php :: import facade laravel 
Php :: shorthand to assign multiple variable to same value in php 
Php :: Nginx + Laravel - Moving blog from subdomain to /blog 
Php :: laravel collection makeVisible 
Php :: list custom post in wp 
Php :: no cache on browser back php 
Php :: how-to-add-pagination-in-search-results wordpress 
Php :: how to get name through id from mysql using php 
Php :: laravel import csv 
Php :: php 8 jit does not work 
Php :: buddy group hide notice join 
Php :: how hide hr tag in post wordpress 
Php :: avoid grouping databases in phpmyadmin 
Php :: login with google account using php source code download 
Php :: delete file in s3 laravel 
Php :: Verifying session info 
Php :: woo can not change products perpage in shop page 
Php :: !array_push($stack, "apple", "raspberry"); 
Php :: laravel factory counter 
Php :: dreamweaver laravel plugin 
Php :: avoid sql injection in password field 
Php :: laravel not rollback even has error 
Php :: function to find total number of students in wplms 
ADD CONTENT
Topic
Content
Source link
Name
5+5 =