DB보내는 곳에서 연락처 중복검사 코딩을 했는데 안되요...
본문
// 연락처 중복검사
$sql = "SELECT * FROM g5_write_online_3 WHERE wr_1 = '{$wr_1}'";
$res = $link->query($sql);
if($res->num_rows >=1) {
echo '이미 존재하는 연락처가 있습니다.';
exit;
}
저걸 그냥 php 파일로 해서 실행했을땐 정상적으로 잘 찾아서 중복검사가 되었는데
그누보드에서 하려니 안되네요... 그누보드에서는 함수를 바꿔줘야 하나요?
<?php include_once("./_common.php"); ?>
<?php
include "mailer.php";
$mode = $_REQUEST['mode'];
$name = $_REQUEST['name'];
$hp1 = $_REQUEST['hp1'];
$hp2 = $_REQUEST['hp2'];
$hp3 = $_REQUEST['hp3'];
$hp = $hp1."-".$hp2."-".$hp3;
$email = $_REQUEST['email'];
$areaname = $_REQUEST['areaname'];
$questype = $_REQUEST['questype'];
$content = $_REQUEST['content'];
$ip = $_SERVER['REMOTE_ADDR'];
$wr_name = $_REQUEST['wr_name'];
$wr_1 = $_REQUEST['wr_1'];
$wr_2 = $_REQUEST['wr_2'];
$wr_3 = $_REQUEST['wr_3'];
$wr_4 = $_REQUEST['wr_4'];
$wr_5 = $_REQUEST['wr_5'];
$subject = "[phone13] $wr_name ($wr_1)";
$body = "";
$body2 = "<table border='0' cellspacing='1' cellpadding='3' bgcolor='#e5e5e5'>";
$body2.= "<tr bgcolor='white'><td align='center' height='25' style='padding:10px'>이 름</td><td align='left' style='padding:10px'>$wr_name</td></tr>";
$body2.= "<tr bgcolor='white'><td align='center' height='25' style='padding:10px'>연락처</td><td align='left' style='padding:10px'>$wr_1</td></tr>";
$body2.= "</table>";
//$admin_email = "받을 메일주소 입력";
$admin_email = "*** 개인정보보호를 위한 이메일주소 노출방지 ***";
if($mode == "send") {
//파일첨부 시작
for($i=1;$i<=3;$i++) {
$file[$i] = $_FILES['userfile'.$i]['name'];
$target[$i] = "./temp/".$file[$i];
if (move_uploaded_file($_FILES['userfile'.$i]['tmp_name'], $target[$i])) {
chmod("$target[$i]", 0777);
}
}
$ret = mailer($name, $email, "Admin", $admin_email, $subject, $body.$body2, $file);
if($file[1] != "") @unlink($target[1]);
if($file[2] != "") @unlink($target[2]);
if($file[3] != "") @unlink($target[3]);
ob_start();
$content = ob_get_contents();
ob_end_clean();
$bo_table = "online_3";
$write_table = $g5['write_prefix'] . $bo_table;
$wr_num = get_next_num($write_table);
$wr_reply = "";
$secret = "secret";
$sql = " insert into $write_table
set wr_num = '$wr_num',
wr_reply = '$wr_reply',
wr_comment = 0,
ca_name = '$ca_name',
wr_option = '$html,$secret,$mail',
wr_subject = '$wr_subject',
wr_content = '$wr_content',
wr_link1 = '$wr_link1',
wr_link2 = '$wr_link2',
wr_link1_hit = 0,
wr_link2_hit = 0,
wr_hit = 0,
wr_good = 0,
wr_nogood = 0,
mb_id = '{$member['mb_id']}',
wr_password = '$wr_password',
wr_name = '$wr_name',
wr_email = '$wr_email',
wr_homepage = '$wr_homepage',
wr_datetime = '".G5_TIME_YMDHIS."',
wr_last = '".G5_TIME_YMDHIS."',
wr_ip = '{$_SERVER['REMOTE_ADDR']}',
wr_1 = '$wr_1',
wr_2 = '$wr_2',
wr_3 = '$wr_3',
wr_4 = '$wr_4',
wr_5 = '$wr_5',
wr_6 = '$wr_6',
wr_7 = '$wr_7',
wr_8 = '$wr_8',
wr_9 = '$wr_9',
wr_10 = '$wr_10' ";
sql_query($sql);
$wr_id = sql_insert_id();
sql_query(" update $write_table set wr_parent = '$wr_id' where wr_id = '$wr_id' ");
sql_query(" insert into {$g5['board_new_table']} ( bo_table, wr_id, wr_parent, bn_datetime, mb_id ) values ( '{$bo_table}', '{$wr_id}', '{$wr_id}', '".G5_TIME_YMDHIS."', '{$member['mb_id']}' ) ");
sql_query("update {$g5['board_table']} set bo_count_write = bo_count_write + 1 where bo_table = '{$bo_table}'");
}
$wr_1 = $uniq;
// 연락처 중복검사
$sql = "SELECT * FROM g5_write_online_3 WHERE wr_1 = '{$wr_1}'";
$res = $con->query($sql);
if($res->num_rows >=1) {
echo '이미 존재하는 연락처가 있습니다.';
exit;
}
?>
답변 1
네 함수를 바꿔야 합니다.
// 연락처 중복검사
$sql = "SELECT count(*) cnt FROM g5_write_online_3 WHERE wr_1 = '{$wr_1}'";
$row = sql_fetch($sql);
if($row['cnt'] > 0) {
echo '이미 존재하는 연락처가 있습니다.';
exit;
}