2026, 새로운 도약을 시작합니다.

폼메일 질문 채택완료

2년 전 조회 1,983

안녕하세요

<form enctype="multipart/form-data" id="form" name="form" method="post" onsubmit="return form_Check();" action="form_send.php';?>">

<input type="text" id="wr_name" name="wr_name" maxlength="4">

~~

</form>

이런식으로 폼메일을 보내고

form_send.php 파일에서 메일을 보냅니다.

근데 스팸으로 들어오는 것들을 보면 이름부분을  4글자로 막아놔도 10글자가 들어오거나

스크립트등을 무시한채 들어와버리더라구요

그래서 form_send.php 파일 자체적으로 외부접속을 막고싶은데요...

form을 통하지 않으면 접속이 안되게? 이런식으로 가능할지요..

write_update 처럼 토큰체크

check_write_token($bo_table);

를 넣어봐도 역시 작동은 안되서...

혹시 다른 방법이 없을까요?

답변 2개

채택된 답변
+20 포인트

토큰 체크를 하는 방법이 적절합니다.

왜 작동이 안되는지를 확인 해야될것 같습니다.

그리고 값 검증은 form_send.php 에서 하는것이 맞습니다.

JavaScript 에서 하는 검증은 클라이언트 조작에 의해 충분히 무효화 될수 있습니다.

로그인 후 평가할 수 있습니다

답변에 대한 댓글 2개

답변감사합니다.

include_once("./_common.php");
check_write_token($bo_table);

는 적용이안되서

check_write_token($bo_table); 이 부분을 어디서 정의하는걸까요?
check_write_token($bo_table); 의 경우

https://github.com/gnuboard/gnuboard5/blob/master/bbs/write_update.php#L6
에서 사용되고 있고

https://github.com/gnuboard/gnuboard5/blob/master/lib/common.lib.php#L3860
에서 정의되어 있습니다.

다음은 DOCUMENT_ROOT 에 임의의 파일을 위치시켜 확인해볼수 있는
폼요청이 넘어간 이후의 값 검증 및
게시판 아이디 기반이 아닌 string 기반 토큰 관련 예제코드 입니다.
[code]
<?php
include 'common.php';

if (empty($_POST['wr_name']) == false) {
if (preg_match('/^.{1,4}$/u', $_POST['wr_name']) !== 1) {
alert('length is too long');
}

$chk = check_write_token('sample_arg');
echo '<hr>';
if ($chk == true) {
echo 'token success';
} else {
echo 'token failure';
}
echo '<hr>';
}
?>

<script>
function form_Check() {
return true;
}
</script>
<form enctype="multipart/form-data" id="form" name="form" method="post" onsubmit="return form_Check();">
<input type="hidden" name="token" value="<?php echo get_write_token('sample_arg'); ?>">
<input type="text" id="wr_name" name="wr_name" maxlength="4">
<input type="submit" />
</form>
[/code]

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

스크립트를 허용처리 안된듯 하니 전송과정중에 이름이 4글자 이상인지 여부 체크하는 기능과
이전페이지가 어디인지 체크하던지 해서 체크하는 방법으로 해보시면 좋을듯 합니다.

로그인 후 평가할 수 있습니다

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

답변을 작성하려면 로그인이 필요합니다.

로그인
🐛 버그신고