주민

[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,560
2년 전 조회 2,345
2년 전 조회 1,384
2년 전 조회 2,252
2년 전 조회 1,714
2년 전 조회 1,476
2년 전 조회 2,374
2년 전 조회 1,817
2년 전 조회 1,430
2년 전 조회 2,312
2년 전 조회 1,928
2년 전 조회 1,566
2년 전 조회 2,067
2년 전 조회 1,837
2년 전 조회 1,335
2년 전 조회 1,507
2년 전 조회 2,622
2년 전 조회 1,800
2년 전 조회 1,813
2년 전 조회 3,576
2년 전 조회 1,100
2년 전 조회 1,724
2년 전 조회 2,814
2년 전 조회 1,979
2년 전 조회 1,335
2년 전 조회 2,522
2년 전 조회 2,420
2년 전 조회 1,885
2년 전 조회 2,774
2년 전 조회 1,798