0

So I have a form which is build up like:

<input name="website['menu']['id']" type="number" value="1">
<input type="text" value="#000000" name="website['color']['primary']['hex']">

Now i want to read out those values in php after they are submit. I tried the following code, but when I var_dump it it gives me null.

if (isset($_POST['website'])) {

    $result = $_POST['website'];

    var_dump($result['menu']['id']);exit;
}
0

2 Answers 2

2

Remove the quote from field name

<input name="website[menu][id]" type="number" value="1">
<input type="text" value="#000000" name="website[color][primary][hex]">

And access the variable in php like:

echo $_POST['website']['menu']['id'];
Sign up to request clarification or add additional context in comments.

Comments

0
Try this,

<?php
print_r($_POST['website']);
print_r($_POST['website']['menu']['id']);
?>
<form action="" method="POST"/>
<input name="website[menu][id]" type="number" value="1">
<input type="text" value="#000000" name="website['color']['primary']['hex']">
<input type="submit" value="submit"/>
</form>

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.