Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to send value attribute from radio button in PHP [closed]

I am struggling with sending the value of a radiobutton to an email.

I have coded 2 radiobuttons, where I have set the first on to be default checked.

The form and values work, however the radio button value is not submitted.

Any wise words?

like image 655
René Hansen Avatar asked Feb 07 '13 09:02

René Hansen


People also ask

How do you post radio button value?

Radio buttons have another attribute - checked or unchecked. You need to set which button was selected by the user, so you have to write PHP code inside the HTML with these values - checked or unchecked.

How do radio buttons work in PHP?

Use the input with type="radio" to create a radio button. Use the same name for multiple radio buttons to define a radio group. Get the value of a checked radio via the $_POST (or $_GET ) variable, depending on the request method.

What is the use of value attribute in radio button?

The value attribute is a string containing the radio button's value. The value is never shown to the user by their user agent. Instead, it's used to identify which radio button in a group is selected.


2 Answers

When you select a radio button and click on a submit button, you need to handle the submission of any selected values in your php code using $_POST[] For example: if your radio button is:

<input type="radio" name="rdb" value="male"/>

then in your php code you need to use:

$rdb_value = $_POST['rdb'];
like image 97
ajmal Avatar answered Oct 15 '22 16:10

ajmal


Check whether you have put name="your_radio" where you have inserted radio tag

if you have done this then check your php code. Use isset()

e.g.

   if(isset($_POST['submit']))
   {
    /*other variables*/
    $radio_value = $_POST["your_radio"];
   }

If you have done this as well then we need to look through your codes

like image 23
Kits Avatar answered Oct 15 '22 15:10

Kits