The following warnings occurred:
Warning [2] count(): Parameter must be an array or an object that implements Countable - Line: 871 - File: showthread.php PHP 7.4.15 (Linux)
File Line Function
/showthread.php 871 errorHandler->error



FORUMS


The Form Tools forums are no longer active, but the old posts have been archived here. Please see the Help page on how to get help / report issues.

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
3 Different Validation Methods - Why?
#1
Hey there,

i took the Demo 3 (Something with Flight/Travel Registration) as Template for my own Form.
I rewrote the code using some of the code already present.
This is where i discovered that you are using three types/methods of Validation.

1. Client-Side Validation with JS and rsv.js.
e.g.
Code:
<script type="text/javascript" src="rsv.js"></script>

  <script type="text/javascript">
  var rules = []

  // Attendee / work information
  rules.push("required,name,Please fill in your name.");

  </script>

2. Server Side Validation with PHP using validate_fields();
e.g.
Code:
$rules = array();
  $rules[] = "required,name,Please fill in your name.";
  $errors = validate_fields($_POST, $rules);


3. Server Side Validation with PHP filling the Error Array by yourself.
e.g.
Code:
if (isset($_POST) && !empty($_POST))
{
  if(!empty($_POST['name']))
        $errors[] = "Please fill in your name.";
}

Is there an advantage in using two or all three Methods at the same time? Or should i choose only one method?
Is the second Method more reliable because Client-Side is JavaScript?
Is the third for checking more complex conditions like the following?
Code:
if(!empty($_POST['a']) && empty($_POST['b']))
        $errors[] = "Please fill in B when providing A.";

Thanks in advance for replies, asgaroth
Reply


Messages In This Thread
3 Different Validation Methods - Why? - by asgaroth - May 23rd, 2011, 3:24 PM
RE: 3 Different Validation Methods - Why? - by Ben - Jun 3rd, 2011, 2:28 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)