주민

[0.1원팁] 그누보드5 stmt 사용 인젝션 보안 적용 기초 select query

안녕하세요 그누보드 주민입니다.

다 알고 계실만한~ 0.1원팁 입니다.

인젝션 injection 공격에 대비하기 위한 가장 기초적인 소스라 도움이 되실지 모르겠습니다.

 

아이디 찾는 query 너무나 간단한 예시)

 

$username="test";

$useremail="test@test1234test.co.kr";

 

$sql="select mb_id, count(*) as total_count from g5_member where mb_name=? and mb_email=?";
//mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT); // 에러 로그 보이게

 

$stmt=$connect_db->prepare($sql);

$stmt->bind_param("ss",$username,$useremail); // ss -> string i -> integer 
$stmt->execute();

 

$result=$stmt->get_result();
$row=$result->fetch_assoc();

$total=$row['total_count'];

  
if($total>=1) {
  echo $row['mb_id'];
}

 

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

그누보드5 팁자료실

+
제목 글쓴이 날짜 조회
2년 전 조회 1,568
2년 전 조회 2,353
2년 전 조회 1,390
2년 전 조회 2,261
2년 전 조회 1,720
2년 전 조회 1,485
2년 전 조회 2,393
2년 전 조회 1,830
2년 전 조회 1,439
2년 전 조회 2,323
2년 전 조회 1,938
2년 전 조회 1,571
2년 전 조회 2,072
2년 전 조회 1,843
2년 전 조회 1,346
2년 전 조회 1,518
2년 전 조회 2,640
2년 전 조회 1,816
2년 전 조회 1,823
2년 전 조회 3,589
2년 전 조회 1,110
2년 전 조회 1,734
2년 전 조회 2,830
2년 전 조회 1,987
2년 전 조회 1,345
2년 전 조회 2,529
2년 전 조회 2,434
2년 전 조회 1,893
2년 전 조회 2,789
2년 전 조회 1,807