테스트 사이트 - 개발 중인 베타 버전입니다

sms 인증번호 보내기

sms 인증번호를 보내기 위한 소스

1. g5_passwd_auth 테이들 생성
// 테이블 : g5_passwd_auth
// auth_id 구분번호
// name 이름
// phone 휴대폰번호
// auth_no 인증번호
// wdate 날짜
//

2. 이름과 휴대전화번호를 받는 폼 작성,
3. action 은 아래의 소스로 받아서 처리
4. sms 관리/전송기록에는 기록하지 않습니다.

====================================
<form name="fform" action="" method="post" autocomplete="off">
<label for="mb_auth_num">이&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;름 &nbsp;&nbsp;<strong class="sound_only">필수</strong></label>
<input type="text" name="mb_auth_name" id="mb_auth_name" class="frm_input" style="width:100px;">

<br /><br />
<label for="mb_auth_phone">휴대폰번호 &nbsp;<strong class="sound_only">필수</strong></label>
<input type="text" name="mb_auth_phone" id="mb_auth_phone" class="frm_input" style="width:100px;">
<input type="button" name="btnPhone" value=" 인증번호 발송 " onclick="authSend();">
<span id="span_phone"></span>
</form>

<script>
function authSend() {
f = document.fform;
name = f.mb_auth_name.value;
phone = f.mb_auth_phone.value;
url = "/theme/jejubbs_com/skin/member/basic/password_lost_phone.send.php";

$.post(url, {"mb_auth_name":name, "mb_auth_phone":phone}, function (data) {
$("#span_phone").html(data);
});
}
</script>
================================
<?php

include_once ("../../../../../common.php");

include_once(G5_SMS5_PATH.'/sms5.lib.php');

$mb_auth_name = $_POST["mb_auth_name"];
if (!$mb_auth_name) {
echo "이름을 입력하세요.";
exit;
}

$mb_auth_phone = $_POST["mb_auth_phone"];
$mb_auth_phone = get_hp($mb_auth_phone, 0); // 받는 사람 휴대전화번호
if (!$mb_auth_phone) {
echo "전화번호를 입력하세요.";
}

$mb_auth_no = mt_rand(100000, 999999); // 100000 ~ 999999 : 6자리 임의의 숫자 만들기


$reply_phone = get_hp($sms5["cf_phone"], 0); // 보내는 사람 휴대전화번호



// 이름과 전화번호를 검색해서 존재하는지 체크
$sql = " select * from g5_member where mb_name = '" . $mb_auth_name . "' and replace(mb_hp, '-', '') = '" . $mb_auth_phone . "' ";
$row = sql_fetch($sql);

if ($mb_auth_name == $row["mb_name"] and $mb_auth_phone == str_replace("-", "", $row["mb_hp"]) ) {

// g5_passwd_auth 테이블에서
// 해당이름과 전화번호로 되어 있는 인증 번호는 모두 삭제한다.
$sql = " delete from g5_passwd_auth where name = '" . $mb_auth_name . "' and phone = '" . $mb_auth_phone . "' ";
sql_query($sql);


// 인증번호 기억하기
$sql = " insert into g5_passwd_auth (name, phone, auth_no, wdate) values (
'$mb_auth_name'
, '$mb_auth_phone'
, '$mb_auth_no'
, NOW()
)";
sql_query($sql);

$SMS = new SMS5;
$SMS->SMS_con($config['cf_icode_server_ip'], $config['cf_icode_id'], $config['cf_icode_pw'], $config['cf_icode_server_port']);

$list = array();
array_push($list, array('bk_hp' => $mb_auth_phone, 'bk_name' => $mb_auth_name));
$result = $SMS->Add2($list, $reply_phone, '', '', "인증번호 " . $mb_auth_no, '', 1);


if ($result) {
$result = $SMS->Send();

if ($result) { //SMS 서버에 접속했습니다.
$SMS->Init(); // 보관하고 있던 결과값을 지웁니다.
echo " 발송완료 (" . date("Y-m-d Y:h:s") . ") ";

} else {
win_close_alert("에러: SMS 서버와 통신이 불안정합니다.");
}
} else {
echo $result;
}

} else {
echo " 일치하는 정보가 존재하지 않습니다.";
}

?>

댓글 작성

댓글을 작성하시려면 로그인이 필요합니다.

로그인하기

댓글 6개

감사합니다..필요했었는데..^^
인증번호 받은 번호가 몇번인지 인증완료되면 한번더 불러올수 있는 방법이 있나요?
select name, phone, auth_no, wdate from g5_passwd_auth
where (name='이름' and phone='전화번호')
인증번호 감사합니다
sms인증번호 보내기 소스

게시글 목록

번호 제목
24318
24317
24315
24309
24294
24293
24277
24262
24260
24253
24251
24236
24233
24228
24226
24221
24214
24203
24201
24199
24196
24195
24194
24192
24191
24187
24185
24183
24172
24168