Validation of radio button on PHP | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Validation of radio button on PHP

i'm trying to validate a radio button so it checks if a radio button has been selected or not

8th Apr 2017, 8:47 AM
Suhaila Mohammed
Suhaila Mohammed - avatar
2 Answers
+ 2
for radio button input form, you just get the value by the name of that radio button to check if it checked/selected. Only the checked radio button that will be submited. eg. if you have <input type="radio" id="a3" name="a" value="3"> <input type="radio" id="a4" name="a" value="4"> and the radio button with value="4" you checked, then you submitted, in php (if you using HTTP POST method) you 'll got $_POST['a'] with value "4" cmiiw
8th Apr 2017, 9:01 AM
cahya dwiana sn
cahya dwiana sn - avatar
+ 1
@cahya thanks mate worked fine🖒
9th Apr 2017, 7:14 AM
Suhaila Mohammed
Suhaila Mohammed - avatar