RBA Cash Rate: 4.35% · 1AUD = 0.67 USD · Inflation: 4.1%  
Leading Digital Marketing Experts | 1300 235 433 | Aggregation Enquires Welcome | Book Appointment
Example Interest Rates: Home Loan Variable: 5.20% (5.24%*) • Home Loan Fixed: 5.48% (6.24%*) • Fixed: 5.48% (6.24%*) • Variable: 5.20% (5.24%*) • Investment IO: 5.78% (6.81%*) • Investment PI: 5.49% (6.32%*)

Checking Form Data & Error Messages

When validating form input, create a unique key and value pair with an associated error message. If, after evaluating all the input, the error array isn't empty, iterate over the array and print the errors.

1
<?php 
2
/*
3
 Checking Form Data & Error Messages
4
 http://www.beliefmedia.com/code/php-snippets/soft-break
5
*/
6
 
7
/* Create array to store error values */
8
$arrErrors = array();
9
 
10
/* Error checking */
11
if (ereg('[^a-zA-Z]', $fn)) $arrErrors['fne'] = 'First name can contain letters only.';
12
if ($fnl < 2) ) $arrErrors['fnl'] = 'First name must be more than two characters.';
13
 
14
/* If errors... */
15
if (count($arrErrors) != 0) {
16
 
17
  /* Add error text to an error string of text */
18
  $strError = '<strong>Please correct the following errors:</strong>
19
<ul>';
20
 
21
    /* Get each error and add it to the error string as a list item */
22
      foreach ($arrErrors as $error) {
23
      $strError .= '
24
<li>' . $error . '</li>
25
 
26
';
27
    }
28
 
29
  $strError .= '</ul>
30
 
31
';
32
 
33
  /* Output error to screen */
34
  echo '
35
<ul>' . $strError . '</ul>
36
 
37
;
38
}

Download our 650-page guide on Finance Marketing. We'll show you exactly how we generate Billions in volume for our clients.

  E. Australia Standard Time [ UTC+10, Default ] [ CHECK TO CHANGE ]

  Want to have a chat?
 

Like this article?

Share on Facebook
Share on Twitter
Share on Linkdin
Share on Pinterest

Leave a comment