faqts : Computers : Programming : Languages : PHP : Common Problems : Forms and User Input

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

59 of 112 people (53%) answered Yes
Recently 3 of 10 people (30%) answered Yes

Entry

Using PHP, how can I can check which radio button is checked and store its value in a variable?

Oct 6th, 2000 20:56
Kiwi Ron, Narendra Jain, Naveen Ghanathe, Ben Udall,


Note: name="gender" is the same for both <input.. lines
<form action="register.php" method="post">
...
<input type="radio" name="gender" value="M"> Male    
<input type="radio" name="gender" value="F"> Female
...
<br>
<input type="submit">
</form>
register.php may have the following code:
<?
...
echo "Gender: [$gender]\n";
...
?>