Functions Dev: Difference between revisions
No edit summary |
No edit summary |
||
| Line 6: | Line 6: | ||
GETPOST() : function to retrieve the content of GET or POST variables in a more secure way. The PHP methods $_GET and $_POST should not be used. | GETPOST() : function to retrieve the content of GET or POST variables in a more secure way. The PHP methods $_GET and $_POST should not be used. | ||
Possible use : | Possible use : | ||
| Line 17: | Line 18: | ||
$myField= GETPOST("myField", 'int'); | $myField= GETPOST("myField", 'int'); | ||
Possible parameters of the second argument : | |||
Possible parameters of the second argument : | |||
*'none' = for no parameter type check | *'none' = for no parameter type check | ||
| Line 30: | Line 32: | ||
*'alphanohtml' = checks that there is no html code | *'alphanohtml' = checks that there is no html code | ||
*'custom' = defined by the following filters and options with the parameters $filter and $options | *'custom' = defined by the following filters and options with the parameters $filter and $options | ||
{| class="wikitable" | {| class="wikitable" | ||
Revision as of 12:02, 31 March 2021
The following page describes some important functions used by dolibarr.
GETPOST
GETPOST() : function to retrieve the content of GET or POST variables in a more secure way. The PHP methods $_GET and $_POST should not be used.
Possible use :
Example in php:
$myField= $_POST["myField"];
becomes if the element passed in parameter is a number :
$myField= GETPOST("myField", 'int');
Possible parameters of the second argument :
- 'none' = for no parameter type check
- 'int' = check that it's a numeric (integer or decimal)
- 'intcomma' = checks that it is an integer with commas ('1,2,3,4...')
- 'alpha' = verifies that it is text and signs
- 'aZ' = verifies that it is a-z only
- 'aZ09' = verifies that it is non-special characters and numbers
- 'array' = verifies that it is an array
- 'san_alpha' = purged string (do not use for free text)
- 'nohtml' = verifies that there is no html code
- 'alphanohtml' = checks that there is no html code
- 'custom' = defined by the following filters and options with the parameters $filter and $options
| Parameters | |
|---|---|
| 'none' | |
| 'int' | |
| 'intcomma' | |
| 'alpha' | |
| 'aZ' | |
| 'aZ09' | |
| 'array' | |
| 'san_alpha' | |
| 'nohtml' | |
| 'alphanohtml' | |
| 'custom' |
For more information see the comments of the function in the file htdocs/core/lib/functions.lib.php
GETPOSTISSET()
GETPOSTISSET(variableName) allows to know if the GET or POST variable passed in parameter is defined.
Example in php:
if (isset($_POST['myField'])){...}
becomes :
if (GETPOSTISSET('myField')){...}
For more information see the comments of the function in the file htdocs/core/lib/functions.lib.php
img_picto
img_picto() function to insert an image.
print img_picto(imagetitle,imagename);
For more information see the comments of the function in the file htdocs/core/lib/functions.lib.php