HOME > 이용안내
이용안내
 
작성일 : 15-01-23 11:21
[스크립트언어] [PHP] php 함수, 외국인 등록번호 체크
 글쓴이 : 제이네트워크
조회 : 37,083  
정부기관에서 발표한 소스입니다.
 
<html>
 <head>
 <title>외국인등록번호 확인</title>
 <META HTTP-EQUIV='Content-type' ConTENT='text/html; CHARSET=euc-kr'>
 <script language=ⓙavascript>
 function check_no(form){
 var fgn_reg_no = document.fgn_check.fgn_reg_no1.value 
+ document.fgn_check.fgn_reg_no2.value;
 
        if (fgn_reg_no == ''){
                 alert('외국인등록번호를 입력하십시오.');
                 return false;
         }
 
        if (fgn_reg_no.length != 13) {
                 alert('외국인등록번호 자리수가 맞지 않습니다.');
                 return false;
         }
 if ((fgn_reg_no.charAt(6) == "5") || (fgn_reg_no.charAt(6) == "6"))
 {
 birthYear = "19";
 }
 else if ((fgn_reg_no.charAt(6) == "7") || (fgn_reg_no.charAt(6) == "8"))
 {
 birthYear = "20";
 }
 else if ((fgn_reg_no.charAt(6) == "9") || (fgn_reg_no.charAt(6) == "0"))
 {
 birthYear = "18";
 }
 else
 {
 alert("등록번호에 오류가 있습니다. 다시 확인하십시오.");
return false;
 } 

birthYear += fgn_reg_no.substr(0, 2);
 birthMonth = fgn_reg_no.substr(2, 2) - 1;
 birthDate = fgn_reg_no.substr(4, 2);
 birth = new Date(birthYear, birthMonth, birthDate);

 if ( birth.getYear() % 100 != fgn_reg_no.substr(0, 2) ||
 birth.getMonth() != birthMonth ||
 birth.getDate() != birthDate) {
 alert('생년월일에 오류가 있습니다. 다시 확인하십시오.');
return false;
 }
 form.submit();
         return true;
 }
 </script>
 </head>
 <boby>
 <form name='fgn_check' method=POST action='fgn_check.php'>
 외국인등록번호 <input type='text' name='fgn_reg_no1' size=6 maxlength=6> - <input type='text' name='fgn_reg_no2' size=7 maxlength=7>
 <input type='button' value='지금 검사' onClick='return form_check(form)'>
 </form>
 </body>
 </html>
 

--------------------------
 <?
if((strlen($fgn_reg_no1) == 6) && (strlen($fgn_reg_no2) == 7)) {
 $sum = 0;
 $odd = 0;
 $reg_no = $fgn_reg_no1."$fgn_reg_no2";

 for($i=0 ; $i < 13 ; $i++) {
         $reg_no[$i] = intval($reg_no[$i]);
 }

 $odd = $reg_no[7]*10 + $reg_no[8];
 
if ($odd % 2 != 0) {
 echo("<script language='ⓙavascript'>
 alert('외국인등록번호에 오류가 있습니다. 다시 확인하십시오.');
history.back();
 </script>");
 }

 if (($reg_no[11] != 6)&&($reg_no[11] != 7)&&($reg_no[11] != 8)&&($reg_no[11] != 9)) {
 echo("<script language='ⓙavascript'>
 alert('외국인등록번호에 오류가 있습니다. 다시 확인하십시오.');
history.back();
 </script>");
 }

 $sum = $reg_no[0]*2 + $reg_no[1]*3 + $reg_no[2]*4 + $reg_no[3]*5 + $reg_no[4]*6 + $reg_no[5]*7 
+ $reg_no[6]*8 + $reg_no[7]*9 + $reg_no[8]*2 + $reg_no[9]*3 + $reg_no[10]*4 + $reg_no[11]*5;
 $sum = $sum % 11;
 $sum1 = 11 - $sum;
 if($sum1 > 9) 
$sum1 = $sum1 % 10;

 $sum1 = $sum1 + 2; 

if($sum1 > 9) 
$sum1 = $sum1 % 10;

 $sum = $reg_no[12];

 if($sum == $sum1) {
 echo("<script language='ⓙavascript'>
 alert ('정상입니다.');
history.back();
 </script>");
 } else {
 echo("<script language='ⓙavascript'>
 alert('외국인등록번호에 오류가 있습니다. 다시 확인하십시오.');
history.back();
 </script>");
 }

 } else {
 echo("<script language='ⓙavascript'>
 alert('외국인등록번호에 오류가 있습니다. 다시 확인하십시오.');
history.back();
 </script>");
 }
 





Cloud server Streaming service Domain Cloud Firewall

 
 

Total 377

번호 제   목   글쓴이 날짜 조회
257 [리눅스서버] 스왑메모리 초기화 혹은 swap 메모리 관리 제이네트워크 2016-05-13 31407
256 [기타] tar 특정폴더에 압축을 풀어야 할 경우 사용 옵션 제이네트워크 2016-05-10 26385
255 [DB] [mysqldump 에러] Got errno 28 on write 발생시 제이네트워크 2016-03-29 28292
254 [윈도우서버] Windows Server 2012R2 (윈도우2012 R2) IIS8.5 서버 FTP 가상디렉토리 설정 제이네트워크 2016-03-25 33478
253 [리눅스서버] [우분투]ubuntu 15.10 서버 네트워크 설정 및 ufw 방화벽 제이네트워크 2016-03-24 30672
252 [리눅스서버] 우분투15.10 서버에서 SSH접속 안될 때 [에러-서버와 매치되는 outgoing encryption … 제이네트워크 2016-03-17 32751
251 [PHP] php 에러시 Warning: date(): It is not safe to rely on the system's timezone settings 제이네트워크 2016-02-03 23005
250 [DB] phpMyAdmin 4.x 버전에서 필요없는 에러메세지 없애는 방법 제이네트워크 2016-02-01 26974
249 [쉘스크립트] /bin/sh^M: bad interpreter: No such file or directory 오류 발생 시 제이네트워크 2016-01-22 28863
248 [리눅스서버] 리눅스 에서 Apche / php / mysql 컴파일 옵션 확인하기 제이네트워크 2015-12-09 27605
247 [스크립트언어] [php-openssl] php-4.4.x openssl 추가 모듈 설치 제이네트워크 2015-12-01 31873
246 [스크립트언어] php zip 설치 (ziparchive php extension) 제이네트워크 2015-11-25 41639
245 [스크립트언어] php-5.3.x 확장모듈 cURL 설치 방법 제이네트워크 2015-11-24 39005
244 [스크립트언어] php-4.x.x 의경우 phpize 사용하여 curl 모듈 추가] 제이네트워크 2015-11-24 33204
243 [스크립트언어] php 재컴파일 없이 모듈추가 하는 방법 입니다. 제이네트워크 2015-11-24 38157
242 [스크립트언어] [php]php-5.3.x 버전 부터 Zend Guard Loader 설치 제이네트워크 2015-11-06 31425
241 [리눅스서버] [apache] mod_ruid2 모듈 설치시 에러 mod_ruid2.c:45:28: error: sys/capability.h: No such file … 제이네트워크 2015-11-06 30691
240 [메일] 센드메일-아웃룩에러 중 다른메일메세지가 배달중이거나... 제이네트워크 2015-11-03 27654
239 [스크립트언어] 각언어별 redirect 구문 제이네트워크 2015-10-06 31642
238 [메일] [sendmail]메일 수발신이 느릴때 (sendmail이 정상동작 하나 느리게 작동할 때) 제이네트워크 2015-09-22 30110
237 [DB] [mysql]mysqldump 로 백업시 lock table 에러로 백업이 안되는 경우 제이네트워크 2015-09-17 27903
236 [리눅스서버] CentOS(리눅스)버전, 혹은 APM(apache, php, mysql) 버전 확인하려고 할때 사용하는 … 제이네트워크 2015-09-07 29805
235 [스크립트언어] mysql 설치 후 phpMyAdmin #2002 MySQL 서버에 로그인할 수 없습니다. 해결법 (1) 제이네트워크 2015-09-03 44347
234 [리눅스서버] 리눅스서버에서 chracterset 을 맞출려고 할 때 제이네트워크 2015-08-25 30281
233 [윈도우서버] windows 2008/2012 서버 셋팅후 403 forbbiden 에러시 제이네트워크 2015-07-22 31465
232 [DB] [mysql] Mysql 에러코드 중에 (Got error 134 from storage engine) 나올때 처리법 제이네트워크 2015-06-04 26540
231 [DB] [mysql-5.6.x 설치 후 에러로 실행 안될때 ][Warning] TIMESTAMP with implicit DEFAULT value … 제이네트워크 2015-05-22 37059
230 [리눅스서버] [apche 1.3.x | 2.0.x 2.2 x.2.4.x ] 아파치 버전별 차이점 제이네트워크 2015-05-19 37758
229 [DB] [MS-SQL SERVER 2008 로그 파일 사이즈 줄이기] 제이네트워크 2015-05-12 28293
228 [윈도우서버] IIS7.x / IIS8.x 에서 asp 호스팅시 "Response 버퍼 제한 초과됨 " 오류 제이네트워크 2015-05-11 32101
227 [윈도우서버] [windows2008] SQL Server 액세스를 허용하도록 Windows 방화벽 구성 제이네트워크 2015-05-04 31294
226 [윈도우서버] [iis7.x ASP 에러] An error occurred on the server when processing the URL 제이네트워크 2015-05-04 30920
225 [DB] [mysql] 테이블 복사하기 (데이타포함, 비포함) 제이네트워크 2015-04-28 28031
224 [스크립트언어] [jquery] 파일 업로드 전에 파일사이즈 체크하기 제이네트워크 2015-04-28 40464
223 [윈도우서버] Windows Server 2008/2012 (64bit OS) - IIS7에서 32bit ASP 응용프로그램 사용법 제이네트워크 2015-04-27 31398
222 [윈도우서버] [windows server 2012 원격데스크톱 세션 늘리기] 제이네트워크 2015-04-27 32937
221 [윈도우서버] [IIS 8.x 설치 후 HTTP오류 404.3 오류 및 asp / asp.net 실행오류] 제이네트워크 2015-04-21 37660
220 [기타] [XE 1.8 설치시 에러]XE cannot connect to DB 제이네트워크 2015-04-11 31237
219 [DB] mysql 외부에서 접속 허용하기 (1) 제이네트워크 2015-04-08 33132
218 [리눅스서버] 리눅스서버에 VNC SERVER 설치 하기 (centos5.8~ 6.7 까지 되네요) 제이네트워크 2015-03-19 36609
 1  2  3  4  5  6  7  8  9  10