Extract function for non arrays.

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
mimi9753
Forum Newbie
Posts: 1
Joined: Tue Jul 15, 2008 11:12 pm

Extract function for non arrays.

Post 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!
User avatar
Oren
DevNet Resident
Posts: 1640
Joined: Fri Apr 07, 2006 5:13 am
Location: Israel

Re: Extract function for non arrays.

Post 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.
User avatar
omniuni
Forum Regular
Posts: 738
Joined: Tue Jul 15, 2008 10:50 pm
Location: Carolina, USA

Re: Extract function for non arrays.

Post 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
Post Reply