PDA

View Full Version : using globalize(STR_NOHTML, INT, etc...)


Oreamnos
06-03-2005, 12:01 AM
I am trying to use vB's globalize function to check, trim, and validate data. I am using this:
globalize($_REQUEST, array(
'field1'=>STR_NOHTML,
'field2'=>INT
));

I have 2 questions about what this function returns and additional arguments it can take
1. if field2 is not an integer, how do I know or check?
2. if field1 is required is there an argument that will check that the field is not blank. for example something like 'field1'=>STR_NOHTML, REQUIRED

thanks in advance
eric

Adrian Schneider
06-03-2005, 12:07 AM
Globalize doesn't check it, just forces it as that. So if the integer is an A, it will be set as 0.

For making it required, you could do a a check like:

if (empty($_REQUEST['eggnog']))
{
$errormessage = "Invalid brand of eggnog specified.";
eval('print_output("' . fetch_template('STANDARD_ERROR') . '");');
}

Andreas
06-03-2005, 12:07 AM
1. You don't know, it will just be zero then.
If you want to check oyu must use $_REQUEST['field1']
2. No. If it is required you must check this yourself and issue an error if it is empty.

Oreamnos
06-03-2005, 03:36 AM
Thanks guys. that helps a lot!