I’m figuring this problem:
I have the $_POST['user'] variable. If I print_r this variable I get:
Array (
['name'] => Your name
['phone'] => Your phone number
['email'] => Your email
)
But if I try to use $_POST['user']['name'], nothing happens, it’s an empty value.
It also happens if I set $_POST['user'] to a variable, for example $user, when I print_r $user I get the same array result, but if I try to work with $user['name'] it’s blank.
This is the input data that has been submited
<input type="text" name="user['name']" value="Your name" class="general-user user-name-style" />
<input type="text" name="user['phone']" value="Your phone number" class="general-user user-data" />
<input type="text" name="user['email']" value="Your email" class="general-user user-data right-user" />
Am I working around in a wrong way with arrays?
The apostrophes are included in the keys, i.e. you get “‘name'” as opposed to “name”.
Try $_POST[‘user’][“‘name'”]
To solve the problem, remove the apostrophes from your HTML code: