• My PHP Pages

    This is a complete and free PHP programming course for beginners. Everything you need to get started is set out in section one below.

Jun 23, 2013

Posted by Unknown
11 comments | 9:45 AM

Today we gonna talk about how to work with radio buttons using php. a sample radio button image is bellow. Lets create a sample HTML code.




File name : radio.html

<html>
<head>
<title>radio form</title>
</head>

<body>

<form name="radiobtnform" method="post" action="process.php">

<form name="radiobtnform" method="post" action="process.php">
<label>Gender : </label>
<input type="radio" name="gender" value="male"/>Male
<input type="radio" name="gender" value="female"/>Female
<input type="submit" name="sendgender" value="Send"/>
</form>

</send>
</html>

Ok.. now we have done with html file. today i'm going to get form data to separate php file. so as we have talked in previous Form lesson i should set php file name to action attribute value. you can see that i have set action attribute value as process.php.

File name : process.php

<?php

if(isset($_POST['sendgender']))
{
$selected_radio = $_POST['gender'];
echo "You are : ".$selected_radio;
}

?>






11 comments :

  1. how about checkbox in php?

    ReplyDelete