본문 바로가기

프로그래밍/Javascript

미성년자 나이 체크

<?
  $jumin =$_POST["jumin"]; 

  $now_year=date("Y",time());
  $now_month=date("m",time());
  $now_day=date("d",time());

  $birth_year=substr($jumin,0,2);
  $birth_month=substr($jumin,2,2);
  $birth_day=substr($jumin,4,2);

  $sex = substr($jumin,6,1);

  if($sex=="1" || $sex =="2"){
   $full_year="19".$birth_year;
  }else if($sex=="3" ||$sex =="4"){
   $full_year="20".$birth_year;
  }

  $age=$now_year-$full_year;
  
  
  
   

  $man_age=$age;

  if($now_month<$birth_month){
   $man_age=$age-1;
  }else if($now_month==$birth_month){
   if($now_day<$birth_day){
    $man_age=$age-1;
   }
  }

  if($man_age>20){
   echo "성인일세";
  }else{
   echo "만 20세 이상만 가입 가능합니다.";
  }

?>

<form name="test" method="post" action="ttt.php">
<input type="text" name="jumin">
<input type="submit" value="전송">
</form>

 

'프로그래밍 > Javascript' 카테고리의 다른 글

자바스크립트 포스트백없이 alert, confirm  (0) 2013.10.22
미성년자 체크  (0) 2012.11.22
Navigator 객체  (0) 2012.11.06
엔터  (0) 2012.09.03
제이쿼리 달력  (0) 2012.08.14