M
M
McFkr2019-02-04 17:48:48
symfony
McFkr, 2019-02-04 17:48:48

How to get value from POST request?

There is a form. The post request passes a value from an input called user[name]. How to access this value from the handler?

Answer the question

In order to leave comments, you need to log in

5 answer(s)
M
Maxim Fedorov, 2019-02-04
@McFkr

If the Symfony tag is not just like this:
Source: https://symfony.com/doc/current/components/http_fo...

A
AUser0, 2019-02-04
@AUser0

Whoa, flashmoooob!
$_POST['user']['name']

S
Soslan Khloev, 2019-02-04
@hloe0xff

$_POST['user']['name']

E
eternalfire, 2019-02-04
@eternalfire

$_POST['user']['name']

K
Kalombyr, 2019-02-04
@Kalombyr

As to a normal multidimensional array. php.net/manual/en/language.types.array.php

<?php

$user = null;

if (array_key_exists('user', $_POST)) $user = $_POST['user']; 
 
if (is_null($user) || !is_array($user)) die('Wrong format');

echo $user['name'];

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question