Hello Friends
I Want to insert value using the HTML radio button in PHP with the MYSQL database. For example -
If I check the male radio button then the male value should be inserted into the MySQL database and if I check the female radio button then the female value should be inserted into the database.
My Mysql database structure.

I am attaching a screenshot of the PHP code.

This operation is related to inserting data using the HTML radio button.
If you want to add a radio button then you should create a form with radio buttons.
For example -
<input type="radio" name="ab" value="Male">Male
<input type="radio" name="ab'" value="Female"> Female
Use PHP code and POST radio data using the POST method
$gender=$_POST['ab'];
Insert this $gender variable value into the database.
Note -
1. The radio button name should the same for both.
2. Use the radio button name to insert data by POST Method
Thanks for the question here. I am here to help you. You are not described well with your HTML and PHP code. You should not include a code screenshot. You should include code only with description. I am understanding your concern. You want to insert radio button data like gender male or female in the database using PHP and MYSQL database. It's really simple.
Let's follow the steps -
Step 1 - First of all create a database using the query
CREATE TABLE `data` (
`id` INT( 50 ) NOT NULL ,
`name` VARCHAR( 40 ) NOT NULL ,
`gender` VARCHAR( 30 ) NOT NULL ,
);
In the query above, I created three columns and a table name. We use the gender column and will insert male or female values.
Step 2- Now you need to create an HTML form with one input box and two radio buttons.
Let's have a look -
<form action="" method="post"
Name:-
<input type="text" name="name"><br><br>
Gender :-
<input type="radio" name="gender" value="Male">Male
<input type="radio" name="gender" value="Female">Female
<input type="submit" value="Submit" name="submit">
</form>
Step 3- If you want to insert gender in the database, you have to create PHP code with MYSQL query
Let's create a PHP script to insert gender Male or Female in PHP.
<?php
$databaseHost = 'localhost';
$databaseName = 'records';
$databaseUsername = 'root';
$databasePassword = '';
$mysqli = mysqli_connect($databaseHost, $databaseUsername, $databasePassword, $databaseName);
if(isset($_POST['submit']))
{
$name = $_POST['name'];
$gender = $_POST['gender'];
$result = mysqli_query($mysqli,"insert into data values('','$name','$gender')");
if($result)
{
echo "Data inserted ";
}
else{
echo "Something wrong";
}
}
?>
Execute the code above. In this way, you can insert gender male or female in the database.
If you have another issue, you can discuss it in the comment.
In one HTML form, when I enter voucherno, why is it not going to another table automatically because they have the same voucherno column?
If I check the male radio button, then the male value should be inserted into the MySQL database, and if I check the female radio button, then the female value should be inserted into the database.