1,105,556 Community Members

Radio button and POST method

Member Avatar
icohibari
Newbie Poster
3 posts since Jan 2013
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
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.

Member Avatar
broj1
Posting Virtuoso
1,580 posts since Jan 2011
Reputation Points: 220 [?]
Q&As Helped to Solve: 220 [?]
Skill Endorsements: 21 [?]
Featured
 
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>
Member Avatar
Bachov Varghese
Posting Whiz in Training
205 posts since Sep 2011
Reputation Points: 45 [?]
Q&As Helped to Solve: 52 [?]
Skill Endorsements: 6 [?]
 
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 three months: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article