creating form using javascript
var mapForm = document.createElement("form");
mapForm.method = "POST";
mapForm.action = "/Application/index.php/ApplicationController/request";
var dataArray = {name: "first", lastName: "second"};
var mapInput = document.createElement("input");
mapInput.type = "hidden";
mapInput.name = "data[]";
mapInput.id = "data[]";
mapInput.value =dataArray;
mapForm.appendChild(mapInput);
document.body.appendChild(mapForm);
mapForm.submit();
here is my code to retrieve form data
if (isset($_POST['data'])) {
$result_array=$_POST['data'];
echo 'Data'.$result_array['name'];
but it shows
Severity: Notice
Message: Undefined index: name
how to solve this. Thanks in advance