0

I have got code from a website as:

<input type="text" class="username" name="f[username]" />

While when I want to get form value in php as

echo $_POST["f[username]"];

It shows nothing

3
  • 2
    check print_r($_POST); and you will come to know how to get value Commented Jun 16, 2016 at 7:06
  • Try echo $_POST["f['username']"]; Commented Jun 16, 2016 at 7:07
  • This is NOT how nested arrays work. :P Commented Jun 16, 2016 at 7:14

3 Answers 3

1

While when I want to get form value in php as

echo $_POST["f[username]"];

Well that's not how you get it.

echo $_POST["f"]["username"];
Sign up to request clarification or add additional context in comments.

Comments

1

PHP special cases [] characters in field names in data which populates $_POST and $_GET. It uses them to generate arrays.

$_POST['f']['username']

Comments

0

Well another answer from planet, don't make yourself hard to solve something, just change the name with familiar

<input type="text" class="username" name="username" />

then echo it in your php

echo $_POST['username'];

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.