Wednesday, 9 April 2014

To Calculate Age Using PHP

Here you can find the Age Calculator using PHP.

Here you can find the code please click below
DEMO

Index.php 

<?php
if(isset($_POST['submit']))
{
$dd=$_POST['dd'];
$mm=$_POST['mm'];
$yy=$_POST['yy'];
$age = (date("md", date("U", mktime(0, 0, 0, $dd, $mm, $yy))) > date("md") ? ((date("Y")-$yy)-1):(date("Y")-$yy));
echo "Your Age is:".$age;
}
?>

<html>
<head>
<title>To Calculate Age Using PHP</title>
</head>
<body>
<form method="post">
<label>D.O.B :</label>
<select name="dd" required>
<option value="">Date</option>
<?php
for($dd=01;$dd<=31;$dd++)
{
echo "<option value='$dd'>$dd</option>";
}
?>
</select>

<select name="mm" required>
<option value="">Month</option>
<?php
for($mm=01;$mm<=12;$mm++)
{
echo "<option value='$mm'>$mm</option>";
}
?>
</select>

<select name="yy" required>
<option value="">Year</option>
<?php
for($yy=2004;$yy>=1980;$yy--)
{
echo "<option value='$yy'>$yy</option>";
}
?>
</select>
<input type="submit" name="submit" value="find">

</form>
</body>
</html




 


No comments:

Post a Comment

Printing first 50 Fibonacci numbers Using PHP Program

Fibonacci series is a series of numbers in which each number is the sum of the two preceding numbers. For example. 0 , 1 , 1 , 2 , 3 , 5...