Basic Info | Database | Display | Forms | Monju | Session | Users

form_prepare

form_prepare($method, $target, $rules)

Description

form_prepare takes data from either the GET or POST super global and sanitizes, and filters it against an optional set of rules. The santizing is tailored to a specific target. It then appends a digital signature to the return array so that you may validate the array contents in the future.

Parameters

$method: (GET, POST) The super global which contains the form data. [type:array]

$target: EMAIL, DATABASE, or BROWSER. [type:string]

$rules:

  • $rules['%name%']: form field name [type:string]
  • $rules['%name%'][0]: false (not required), true (required) [type:boolean]
  • $rules['%name%'][1]: Input rule [type:string] Accepted rules: (ALNUM: Alphanumeric characters only; ALPHA: Alphabetic characters; DIGIT: Digits only; LOWER: lowercase ALPHA only; NUMERIC: is of PHP type:numeric; UPPER: uppercase ALPHA only; STRING: is of PHP type:string; /REGEX/: REGEX represents a valid REGEX string.

Return Values

On Success: Sanitized form data [type:array] On Failure: False[type:boolean]

Notes

The signature can be found in the array field 'monju_hash'

Examples

$rules['identifier'][0] = true; $rules['identifier'][1] = ALPHA; $rules['email'][0] = true; $rules['email'][1] = '/.*@[a-z]+\.com/'; $prepared = form_prepare('POST', 'DATABASE', $rules); // can now use in form_dispatch()

Dependencies

- monju.lib.php

Comments

Support the Docs!

If you notice a mistake in the documentation, instead file a bug report in the issue tracker. Instead use this to add tips and tricks associated with the functions. You can use tags like to keep your comments clear.