How to create program in php for find age by Date of birth?

8

<?php

if(isset($_POST[‘btn’]))

{

$year  = (date(“Y”)1) – $_POST[‘year’];

$month = date(“m”) $_POST[‘month’];

$day   = date(“d”)$_POST[‘day’];

echo “your date of birth is “.$_POST[‘day’].“-“.$_POST[‘month’].“-“.$_POST[‘year’].“<br>”;

echo “your age is $month month $year”;

}

?>

<html>

<head>

<title>PHP Example</title>

</head>

<body>

<form action=“” method=“post”>

<?php

echo “select Your date of birth”;

$month_array=array(“January”,“February”,“March”,“April”,“May”,“June”,

“July”,“August”,“September”,“October”,“November”,“December”);

 

echo “<select name=\”day\”>”;

$i = 1;

while ( $i <= 31 ) {

   echo “<option value=”.$i.“>”.$i.“</option>”;

   $i++;

}

echo “</select>”;

echo “<select name=\”month\”>”;

$i = 0;

while ( $i <= 11 ) {

   echo “<option value=”.$month_array[$i].“>”.$month_array[$i].“</option>”;  

   $i++;

}

echo “</select>”;

echo “<select name=\”year\”>”;

$i = 1900;

while ( $i <= 2007 ) {  

   echo “<option value=”.$i.“>”.$i.“</option>”;  

   $i++;

}

echo “</select>”;

?>

</form>

</body>

</html>

Please follow and like us:
0

Add a Comment

Your email address will not be published. Required fields are marked *