Revision: 47911
Updated Code
at June 18, 2011 02:58 by vigv
Updated Code
$method = 'GET';
$count = 0;
$errorArray = array();
$inputName = array('vit_name', 'vit_nickname', 'vit_test');
$inputDesc = array('Name', 'Nickname', 'Test');
if($_SERVER['REQUEST_METHOD']==$method) {
$name = '_'.$method;
foreach($inputName as $ele) {
if ( empty(${$name}[$ele]) ) { array_push($errorArray, "Please enter a ".$inputDesc[$count]."."); }
else { }
$count++;
}
if( !empty($errorArray) ) {
for($i=0;$i<sizeof($errorArray);$i++) {
echo $errorArray[$i]."<br />";
}
}
}
Revision: 47910
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at June 18, 2011 02:57 by vigv
Initial Code
<?php
$method = 'GET';
$count = 0;
$errorArray = array();
$inputName = array('vit_name', 'vit_nickname', 'vit_test');
$inputDesc = array('Name', 'Nickname', 'Test');
if($_SERVER['REQUEST_METHOD']==$method) {
$name = '_'.$method;
foreach($inputName as $ele) {
if ( empty(${$name}[$ele]) ) { array_push($errorArray, "Please enter a ".$inputDesc[$count]."."); }
else { }
$count++;
}
if( !empty($errorArray) ) {
for($i=0;$i<sizeof($errorArray);$i++) {
echo $errorArray[$i]."<br />";
}
}
}
?>
Initial URL
Initial Description
A simple and dynamic server-side form validation script. Setup: 1. Insert the field names in the $inputName array and the field descriptions in the respective array pointers in the $inputDesc array. 2. Change the $method to the respective method chosen.
Initial Title
Simple and Dynamic Server-side Form Validation
Initial Tags
Initial Language
PHP