Reputation: 336
Everybody, I'm have an $_POST['input']
request with this:
Array
(
['Имя'] =>
['Город'] =>
['Контактный телефон'] => sdfsdf
['email'] => sdfsdf
['Площадь(м2)'] =>
['Материал'] =>
['Толщина стен(мм)'] =>
['Высота потолков(мм)'] =>
['Кол-во окон'] =>
['Топливо'] =>
['Пожелания'] => asdasd
)
How to get value of the element of this array, something like $_POST['input']['email']
for example (this does not work)?
Upvotes: 1
Views: 70
Reputation: 47169
The issue here is that you have single quotes around the word 'email'
inside the array key:
Notice the difference:
<?php
$_POST['input'] = array ('...' => '...',
'email' => 'xyzabc',
"'email'" => 'sdfsdf');
Array
(
[input] => Array
(
[...] => ...
[email] => xyzabc
['email'] => sdfsdf
)
)
So in order to correctly get the key you need to check it as follows:
if (isset($_POST['input']["'email'"])) {
echo $_POST['input']["'email'"];
}
Result:
sdfsdf
Upvotes: 2
Reputation: 9546
$_POST['input']['email']
is the correct place to look.
Check if your the names are exact "email" (may be cirilic E in one of the places ?)
Try some of the others:
echo $_POST['input']['Имя']
You may need to check if the request is empty:
$email = isset($_POST['input']['email'])? $_POST['input']['email'] : 'no email';
Upvotes: 0
Reputation: 707
if this has been submitted though post request just look for $_post['email'].
Upvotes: 0
Reputation: 21261
Do not write
$_POST['input']['email']
Write
echo $_POST['email']
And it will output sdfsdf
Upvotes: 0