Two Factor Authentication via Google Authenticator is now required to login. Please submit a support ticket if you have questions or issues. close

Home Documentation 1.2.2 Web Developers Common Tasks & Objects Retrieving GET & POST data


Retrieving GET & POST data

JRequest 'getVar' method

To retrieve GET/POST request data, use the getVar method of the JRequest class (JRequest::getVar()).

Retrieving Data

If you have a form variable named 'address', you would want to use this code to get it:

$address = JRequest::getVar('address');

Unless other parameters are set, all HTML and trailing whitespace will be filtered out.

The DEFAULT Parameter

If you want to specify a default value in the event that 'address' is not in the request or is unset, use this code:

$address = JRequest::getVar('address', 'Address is empty');
echo $address;  // Address is empty

The SOURCE Parameter

Frequently, you will expect your variable to be found in a specific portion of the HTTP request (POST, GET, etc...). If this is the case, you should specify which portion; this will slightly increase your extension's security. If you expect 'address' to only be in POST, use this code to enforce that:

$address = JRequest::getVar('address', 'default value goes here', 'post');


The fourth parameter of getVar() can be used to specify certain filters to force validation of specific value types for the variable.

$address = JRequest::getVar(
    'default value goes here',
    'variable type'

Here is a list of types you can validate:

  • INT
  • BOOL
  • WORD
  • CMD
  • BASE64
  • PATH

The FILTER MASK Parameter

Finally, there are some mask constants you can pass in as the fifth parameter that allow you to bypass portions of the filtering:

$address = JRequest::getVar(
    'default value goes here',
    'validation type',
    'mask type'
  • JREQUEST_NOTRIM - prevents trimming of whitespace
  • JREQUEST_ALLOWRAW - bypasses filtering
  • JREQUEST_ALLOWHTML - allows most HTML. If this is not passed in, HTML is stripped out by default.

Last modified: