views:

117

answers:

2

I'm working on a wordpress plugin, and have come across a barrier of sorts. I need to take in a value from a textbox from the options page, but I don't want that information stored within the options.php file. Instead, I need to get that value, and then store it within an array, and later that array will be filed into the options.php file.

How would I go about doing this?

A: 

You can split the contents of the text box using explode:

$array = explode("\r\n", $_POST['textarea']);
Sundeep
how would I know which text area $_Post is referring to? Page consists of 3 different forms.
Sakamoto Kazuma
A: 

Having 3 different forms on the page is going to cause issues in itself. When you submit 1 form, it isn't going to grab all the information from the other 2.

I am not sure why you would need to have 3 different forms on the page, but if it is a necessity, and you want to capture all the information, you would have to submit using some javascript. All 3 forms would have to call a javascript when submitted that would compile the information and submit it to the next page, otherwise you will lose data.

If you need to explode it, you can use the something like what Sundeep mentioned, if you would want the information to come across already in an array you could just name your inputs accordingly:

<textarea name="info[text_area1]">Default value here</textarea>
<textarea name="info[text_area2]">Default value here</textarea>

And so on, then when submitted to the next page $_POST/$_GET['info'] would be the array of all your inputs, $_POST['info']['text_area1'] etc...

I would however say combine the forms if at all possible, it would make submitting much easier.

Jimmy
Trying to make it so that user can change certain things, but they don't have to change all features if they don't want to.
Sakamoto Kazuma