Page 1 of 1

Extract function for non arrays.

Posted: Tue Jul 15, 2008 11:17 pm
by mimi9753
I'm working on a form where it checks to see if data was entered into each form field. If a field is blank, I want the form to show again, but I want data entered in the other fields to be preserved. I want to use an extract() like function...but my variables are not in array. Is there another function that I can use to extract variables and not an array?

Thanks for your help!

Re: Extract function for non arrays.

Posted: Tue Jul 15, 2008 11:27 pm
by Oren
Did you read what the php manual says about extract?
Warning

Do not use extract() on untrusted data, like user-input ($_GET, ...). If you do, for example, if you want to run old code that relies on register_globals temporarily, make sure you use one of the non-overwriting extract_type values such as EXTR_SKIP and be aware that you should extract in the same order that's defined in variables_order within the php.ini.
Anyway, you don't need extract or any other function. Instead, I'd better write your own functions to validate the data and process it accordingly.

Re: Extract function for non arrays.

Posted: Tue Jul 15, 2008 11:41 pm
by omniuni
Very simply use if($_POST['data1'] && $_POST['data2'] && $_POST....)


it will check to make sure everything is "true" or has had information entered.

-Omni