homepage Welcome to WebmasterWorld Guest from 54.204.127.191
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
getting array values from a form
surrealillusions




msg:4599948
 11:40 am on Aug 7, 2013 (gmt 0)

Hi,

Having some trouble getting some values from input arrays.

Trying out something simple before scaling it up as I need alot more inputs than this.

<input type="text" name="option[one]"/>
<input type="text" name="option[two]"/>
<input type="text" name="option[three]"/>
<input type="text" name="option[four]"/>


Tried various bits to get any values entered into them fields to display, but nothing. Such as the following:


$yourArray = $_POST['option'];
foreach ($yourArray as $attributes){
echo key($yourArray).' '.$attributes.'<br>';
}

foreach ($_POST['option'] as $key => $value) {
echo "<p>".$key."</p>";
echo "<p>".$value."</p>";
echo "<hr />";
}



var_dump ($_POST['option']); gives me 'null'.

I basically need to grab any input field that has something entered into it. There are other fields in the form that need to be separate from this group of fields, so thinking of using input arrays for the solution. But, I cant get the simplest of things to work before checking if the input is empty and naming them correctly.

 

jatar_k




msg:4600122
 8:58 pm on Aug 7, 2013 (gmt 0)

seems like the form is not posting, what's the method of the form set to?

also I always prefer this way to dump post vars, then I don't mess with it

echo '<p>POST:<pre>';
print_r($_POST);
echo '</pre>';

surrealillusions




msg:4600253
 9:56 am on Aug 8, 2013 (gmt 0)

Turned out, even though I was taking things basic on this, the form I put it in that it was going in, isn't and had a few other things going on that conflicted with the input array.

Tried it on a blank page, with just those options and echoing out the input with no data checking, and it worked fine.

Got it all sorted in the end :)

jatar_k




msg:4600312
 3:27 pm on Aug 8, 2013 (gmt 0)

glad you got it sorted :)

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved