1.11M Members

Radio button and POST method

 
0
 

I have a radio box that has a php variable name in its radio name. How can I pass its value to another PHP file and it will become like this, for example:

<input type='radio' name='choice_a' value='$answer'>

It will become a $_POST['choice_a'] after I pass it in another page. But if its like this:

<input type='radio' name='$quiz_no' value='$answer'>

How can its name be passed in another PHP file for checking? By the way, the $quiz_no and $answer is stored in my database.

 
0
 

If the above code is html (not php) then you have to do it this way:

<input type='radio' name='choice_a' value='<?php echo $answer;?>'>
<input type='radio' name='$quiz_no' value='<?php echo $answer;?>'>

To pass this to another php file for checking / processing enclose fields in form tags and set action attribute (and add a submit button):

<form action="anotherfile.php" method="post">
<input type='radio' name='choice_a' value='<?php echo $answer;?>'>
<input type='radio' name='$quiz_no' value='<?php echo $answer;?>'>
<input type="submit" name="submit" value="Submit">
</form>
 
0
 

In your action page fetch all field names from database
&
in your while loop get tha posted values like $_POST['$row->yourFieldName']

You
This article has been dead for over six months: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article