webCOMAND

request::post()

The post method provides access to HTTP (and HTTPS) POST query parameters.  POST parameters are made available to a web page through a form submission or AJAX POST or other HTTP POST request.

Prototype

string post(string $key = NULL, boolean $xss_filter = FALSE)

Parameters

  • key - Name of the parameter to retrieve.  If NULL or no key is provided, an associative array of all parameters will be returned.
  • xss_filter - Optional parameter to enable the cross site scripting filter when available, which converts potentially malicious HTML tags into HTML entities.

Return

If the POST parameter exists, the value is returned as a string, including an empty string.  Otherwise, FALSE is returned.

Example

The following HTML form will POST a "search" parameter with the value "test".

<html>
<body>
    <h1>Search</h1>
    <form method="POST">
        <input name="search" type="text" value="test" />
        <input type="submit" />
    </form>
</body>
</html>

The following PHP code will retrieve the posted search value.

// retrieve the value of the "search" POST parameter
$request = new \io_comand_web\request();
$search = $request->post('search');