RBA Cash Rate: 4.35% · 1AUD = 0.67 USD · Inflation: 4.1%  
Leading Digital Marketing Experts</strong | 1300 235 433 | Aggregation Enquires Welcome | Book Appointment
Example Interest Rates: Home Loan Variable: 5.69% (5.89%*) • Home Loan Fixed: 5.39% (6.59%*) • Fixed: 5.39% (6.59%*) • Variable: 5.69% (5.89%*) • Investment IO: 5.69% (6.48%*) • Investment PI: 5.39% (6.59%*)

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 complimentary 650-page guide on marketing for mortgage brokers. We'll show you exactly how we generate billions in volume for our clients.
Finance Guide, Cropped Top and Bottom
  Timezone: 1 · [ CHANGE ]

Like this article?

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

Leave a comment