2

How to get value in another page using the POST method?

<label>
    <input type="radio" value = "1" name="jsq[1]" checked>1
</label>
<label>
    <input type="radio" value = "2" name="jsq[1]">2
</label></br>
<label>
    <input type="radio" value = "3" name="jsq[1]">3
</label>
<label>
    <input type="radio" value = "4" name="jsq[1]">4
</label></br>
<label>
    <input type="radio" value = "5" name="jsq[1]">5
</label>

I want to get value of jsq[1] in myarr[1]. How can I do that?

$myarr[1] = $_POST['jsq[1]'];
4
  • 3
    $_POST['jsq'][1'] - all of your inputs have the same name so only 1 of the values will come through Commented May 6, 2015 at 14:26
  • 1
    Why using array on radio buttons ? Commented May 6, 2015 at 14:28
  • $myarr[1] = $_POST['jsq'][1]; You might have found it yourself with a simple test by printing the content of $_POST. ;) Commented May 6, 2015 at 14:28
  • @FuzzyTree — They're radio buttons, you're only going to get one of them anyway. Commented May 6, 2015 at 14:33

1 Answer 1

5

Without going into the question why you're naming them jsq[1] an not just jsq...

you're almost there, but it should be

$myarr[1] = $_POST['jsq'][1];

It's by the way always a good idea to check this king of things using print_r($_POST); or var_dump($_POST);

Sign up to request clarification or add additional context in comments.

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.