Here you can find the Age Calculator using PHP.
Here you can find the code please click below
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
Here you can find the code please click below
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