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

폼메일 셀렉박스 - 체크된 셀렉박스 값만 전송받기 채택완료

MisungKim 5년 전 조회 2,433

안녕하세요.   

덕서리님 소스 https://sir.kr/g5_skin/10486" rel="nofollow noreferrer noopener" target="_blank">https://sir.kr/g5_skin/10486 위의 덕서리님 소스를 가지고 폼메일을 사용하고 있습니다.

소스도 간단하고 이상없이 메일로 잘 오는데 

 

제가 어려움을 겪는 부분이

다중 셀렉박스 에서 선택한 값만 메일로 전송되게 하고 싶은데

선택적이 아니라 모든 셀렉박스를 체크해야만 메일이 가집니다. ㅜㅜ

 

select값에 따라 체크된 값만 메일로 전송될 수 있는 방법 없을까요?

고수님들 부탁드립니다. 

 

 

 

메일 html

Q&A

하이포레스트 고객센터 입니다.

무엇을 도와드릴까요?

사업제휴

방송/협찬

유통/판매

홍보/마케팅

제안

프로모션

대량구매

오프라인 미팅요청

Other.

 

 

send.php

if(isset($_POST['email'])) {

$email_to = "info@leesee.co.kr"; // 문의메일 받는 사람 메일 주소

$email_subject = "하이포레스트 '제휴문의'메일 입니다.";

$email_subject = '=?UTF-8?B?'.base64_encode($email_subject).'?=';

 

function died($error) {

// your error code can go here

echo "";

die();

}

// validation expected data exists

if( !isset($_POST['first_name']) ||

!isset($_POST['company_name']) ||

!isset($_POST['phone_num']) ||

!isset($_POST['qna']) ||

!isset($_POST['qna_2']) ||

!isset($_POST['qna_3']) ||

!isset($_POST['email']) ||

!isset($_POST['comments'])) {

died('We are sorry, but there appears to be a problem with the form you submitted.');

}

$first_name = $_POST['first_name']; // required

$company_name= $_POST['company_name']; // required

$phone_num = $_POST['phone_num']; // required

$qna = $_POST['qna'];

$qna2 = $_POST['qna_2'];

$qna2 = $_POST['qna_3'];

$email_from = $_POST['email']; // required

$comments = $_POST['comments']; // required

$error_message = "";

$email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+.[A-Za-z]{2,4}$/';

if(!preg_match($email_exp,$email_from)) {

$error_message .= 'The Email Address you entered does not appear to be valid. ';

}

if(strlen($comments) < 2) {

$error_message .= 'The Comments you entered do not appear to be valid. ';

}

if(strlen($error_message) > 0) {

died($error_message);

}

$email_message = "";

function clean_string($string) {

$bad = array("content-type","bcc:","to:","cc:","href");

return str_replace($bad,"",$string);

}

 

$email_message .= "기업명 : ".clean_string($company_name)."\n\n";

$email_message .= "성함 / 직책 : ".clean_string($first_name)."\n\n";

$email_message .= "문의내용 : ".clean_string($qna).",".clean_string($qna2).",".clean_string($qna3)."\n\n";

$email_message .= "연락처 : ".clean_string($phone_num)."\n\n";

$email_message .= "이메일 : ".clean_string($email_from)."\n\n";

$email_message .= "문의사항 : ".clean_string($comments)."\n\n";

// create email headers

$headers = 'From: '.$email_from;

// 제목이 깨질경우 아래 캐릭터셋 적용

 

@mail($email_to, $email_subject, $email_message, $headers);

?>

}

?>

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

답변 1개

채택된 답변
+20 포인트
5년 전

PHP는 잘 몰라서.  원코드는 send.php로 넘어 가는데

여기서는 action="send_alliance.php" 로 넘어가네요..

 

https://sir.kr/g5_tip/13330">https://sir.kr/g5_tip/13330  를 사용해서 각각을 찍어보세요.. (디버깅하는데 도움이 됩니다.  제일 좋은 것은 xdebug라고 합니다.)

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

답변에 대한 댓글 1개

M
MisungKim
5년 전
아, send.php파일이라고 적었으나 "send_alliance.php" 이 이름으로 연결하였습니다
그리고 제가 디자이너라 올려주신 링크 내용은 이해를 하지 못했습니다
ㅜㅜ 죄송합니다.

(현재 메일이 아예 전송되지 않는 문제는 아니고
셀렉박스를 모두 체크해야지만 메일이 전송되고
몇 개만 골라 선택하면 메일이 가지 않는 것이 문제가 되고 있습니다 ㅜㅜ 흑)

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

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

로그인