O'Reilly logo

Mastering Joomla! 1.5 Extension and Framework Development by Chuck Lanham, James Kennard

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Dealing with CGI request data

It is essential that we sanitize incoming data by removing any unexpected data and ensuring that the data is of an expected type. Joomla! provides us with the static class JRequest, which eliminates the need to directly access the request hashes $_GET, $_POST, $_FILES, $_COOKIE, and $_REQUEST. Using JRequest to its full potential we can perform useful data preprocessing. For detailed information on the JRequest class see Appendix G , Request and Session Handling.

Preprocessing CGI data

To access a request value we must use the static JRequest::getVar() method. In this example we get the value of the input id:

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

If we wish we can define a default value; this is the value that will be returned ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required