사이트 내 전체검색
PHP
[php] 나이를 알아 내어 성인인증을 하는 소스
로빈아빠
https://cmd.kr/php/533 URL이 복사되었습니다.

본문

나이를 알아 내어 성인인증을 하는 소스

* 주민번호 앞자리를 이용하여 성인인증
$_auth = get_age2($_sn,'18');
//나이를 알아내는 함수 - 주민번호 앞자리 사용
//return이 1이면 인증 0이면 미인증
function get_age2($_sn,$_idx)	{
		$_year = substr($_sn,0,2);

		$_toYear = substr(date("Y"),2,2);
		if($_year > $_toYear) { 
				$birth = "19".$_year;
		}	else {
				$birth = "20".$_year;
		}
		$me_age = date("Y") - $birth;
		if($me_age < $_idx) {
				$_auth = 0;
		} else {
				$_days = substr($_sn,2,4);
				if($_days > date("md")) {
						$_auth = 0;
				} else {
						$_auth = 1;
				}
		}
		return $_auth;
}


* 년도를 사용하여 나이를 리턴
//나이를 알아내는 함수
// 1977형태나 77형태 모두 사용가능. 
function get_age($_year)	{
		if($_year > 100) {
				$me_age = date("Y") - $_year;
		} else {
				$_toYear = substr(date("Y"),2,2);
				if($_year > $_toYear) { 
						$birth = "19".$_year;
				}	else {
						$birth = "20".$_year;
				}
				$me_age = date("Y") - $birth;
		}
		return $me_age;
}

댓글목록

등록된 댓글이 없습니다.

PHP
871 (9/18P)

Search

Copyright © Cmd 명령어 52.15.142.53