-1

I have a named form control:

<input class="form-control" name="user['first_name']" value="">

How can I get its value after it has been submitted via POST?

I tried these and none of them seems to work:

echo $_REQUEST['user']->fname;
echo $_POST['user[fname]'];
echo $_POST['user']['fname'];
Nisse Engström
  • 4,636
  • 22
  • 26
  • 40
gaurav
  • 237
  • 3
  • 16

2 Answers2

0

Try this, get all value using foreach loop

foreach ($_POST as $key => $value) {
    //do something
    echo $key . ' has the value of ' . $value;
}
Dave
  • 3,046
  • 7
  • 19
  • 32
0

It's useless because your user['first_name'] will never change, then Mohammad has the good answer, it's $_POST['user']["'first_name'"], but if you want your user['first_name'] to change always, change it to put your php inside like this :

<?php echo "<input class='form-control' name='".$user['first_name']."' value=''>" ?>