<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="
http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
</head>
<body>
<form id="form1" name="form1" method="post" action="">
请输入您的出生日期
<input type="text" name="year" id="textfield" value="<?=isset($_POST['year'])?$_POST['year']:""?>"/>
年
<input type="text" name="mon" id="textfield2" value="<?=isset($_POST['mon'])?$_POST['mon']:""?>"/>
月
<input type="text" name="mday" id="textfield3" value="<?=isset($_POST['mday'])?$_POST['mday']:""?>"/>
日
<input type="submit" name="button" id="button" value="提交" />
</form>
<?
if(isset($_POST['button'])){
$dateold = ($_POST['year']."-".$_POST['mon']."-".$_POST['mday']);
$date = date("Y-m-d") ;
$age = $date-$dateold;
$d=date ("l", mktime (0,0,0,$_POST['mon'],$_POST['mday'],$_POST['year']));
echo "<br>";
echo "您的年龄为:{$age}<br>";
echo "出生时是一周的:{$d}";
}
?>
</body>
</html>