phpschool 의 tip&tech 에 있는 내요입니다..
글쓴이:유희목 [알고리즘]사업자등록번호 체크 조회수:73
유희목
Tip&Tech에 사업자 번호 체크하는 알고리즘이 없네요^^
자바로 하나 있는것 같은데....
구래서 올려드립니다
사업자번호 첫번째는 co_serial_1, 둘째는 co_serial_2, 세번째 자리는
co_serial_3 입니다...
Ex) aaa-bb-ccccc
co_serial_1 = aaa
co_serial_2 = bb
co_serial_3 = ccccc
form 에서 post방식으로 받았을때입니다.^^
중간에 연산하는곳에 substr로 걸러내서 intval로 안정해 줘도 연산이 잘 되네
요^^ 에러나는분은 고쳐서 쓰시던지요~~~^^
<?
function error_msg($message)
{
echo("
");
exit;
}
$co_serial_1 = $HTTP_POST_VARS[co_serial_1];
$co_serial_2 = $HTTP_POST_VARS[co_serial_2];
$co_serial_3 = $HTTP_POST_VARS[co_serial_3];
if (!isset($co_serial_1) || !isset($co_serial_2) || !isset
($co_serial_3))
{
error_msg("사업자등록번호를 입력해 주세요.");
}
elseif (ereg("[^0-9]+",$co_serial_1) || ereg("[^0-9]+",$co_serial_2) ||
ereg("[^0-9]+",$co_serial_3))
{
error_msg("사업자등록번호를 정확히 입력해 주세요.");
}
else
{
$co_serial = $co_serial_1.$co_serial_2.$co_serial_3;
$IDtot = 0;
$IDAdd = "137137135";
for ($i=0;$i < 9 ; $i++)
{
$IDtot = $IDtot + (substr($co_serial,$i,1) * substr($IDAdd,$i,1));
}
$IDtot = $IDtot + ((substr($co_serial,8,1)*5)/10);
$IDtot = 10 - ($IDtot % 10);
if (substr($co_serial_3,-1) != substr($IDtot,-1))
{
error_msg("사업자등록번호를 정확히 입력해 주세요.");
}
}
?>
즐프하세요~~~
php
bibaram2005.02.18 · 1분 읽기 · 조회 4,947
[알고리즘]사업자등록번호 체크
bibaram2005.02.18 · 1분 읽기 · 조회 4,947이어서 읽기
html↗
favicon.ico Status 404 해결방법
favicon.ico 파일이 있어서 경로를 직접 설정해주는 게 최선이지만favicon.ico가 없다면 아래와 같이 넣어준다. <html> <head> <link rel="shortcut icon" href="data:image/x-icon;," type="image/x-icon"> </head…
2020.09.25·1분 읽기
php↗
Codeigniter api에서 어떤 곳에서 보낸 json
$aData = var_export(file_get_contents('php://input'),TRUE); $aArr = json_decode(str_replace("'", "", $aData), true); 버전에 따라 다를 수도 있음 $this->input->raw_input_stream 이렇게 해보면 됨
2020.09.11·1분 읽기
server↗
apache 이미지 로그 안쌓이게 하기
웹서버를 운영하다 보면 Apache log 가 엄청나게 많이 쌓인다. logrotate 가 실행되고 있다면 어느 정도 로그가 정리가 되겠지만 아니라면 로그가 쌓여서 서버가 엄청 느려지거나 서버가 다운될 수도 있다. ErrorLo…
2020.02.17·2분 읽기
댓글 0
아직 댓글이 없습니다.