| Viewed 311 times

How know which radio button is selected via PHP?

How know which radio button is selected via PHP?

1 Answer
Mohammad Qandeel

The radio button is used to force the user to choose only one option from a selection
so for example when you complete a payment, you are asked to choose only one payment method from the payment method group


<form method="GET">
    <label for="f-check">MasterCard
        <input type="radio" name="Payment" value="1" id="f-check">
    <label for="s-check">Paypal
        <input type="radio" name="Payment" value="2" id="s-check">
    <input type="submit">

input tag need these attributes to work

  • type  =radio
  • name=any-name -be sure to choose one name for the same group
  • value=each individual element has a different value


after that, we will handle the form request when the user submits the form using PHP

add below code to the same HTML form page

        echo $Payment;


Related Questions