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

폼메일 코드 수정 채택완료

굼떠 4년 전 조회 3,467

덕서리님이 올려주신 코드를 응용해서 작업중입니다.

 

이름,연락처, qna[문의유형] 값만 받고 싶은데 html에서 이메일 tr 을 삭제해버리면 아예 작동을 안하네요...

어떻게없앨 수 있을까요?

 

 

</p>

<p><meta charset="utf-8">

<?php

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

$email_to = "test@test.com"; // 문의메일 받는 사람 메일 주소

$email_subject = "수강문의";

$email_subject = '=?UTF-8?B?'.base64_encode($email_subject).'?=';</p>

<p>function died($error) {

// your error code can go here

echo "<script> alert('이메일형식을확인해주세요.');";

echo "history.go(-1);";

echo "</script>";

die();

}

// validation expected data exists

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

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

!isset($_POST['qna']) ||  // 이부분이 다중체크값!!!입니다.

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

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

}

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

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

$email_from = $_POST['email']; // required</p>

<p>$list = $_POST['qna'];  // 이부분이 다중체크값!!!입니다.

echo $list[0];

echo $list[1];</p>

<p>$list = implode(', ', $_POST['qna']);

$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($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);

}</p>

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

$email_message .= "문의내용 : ".clean_string($list)."\n\n";

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

$email_message .= "이메일 : ".clean_string($email_from)."\n\n";  // 이부분이 다중체크값!!!입니다.

// create email headers

$headers = 'From: '.$email_from;

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

<p>@mail($email_to, $email_subject, $email_message, $headers);

echo "<script> alert('상담 신청이 완료되었습니다.');";

echo "history.go(-1);";

echo "</script>";

?>

<?php

}

?>

 </p>

<p>

 

 

</p>

<p><div class="contact_form application">

    <div class="row">

         <form name="contactform" method="post" action="formtest.php" class="main_form_wrap">

            <table>

               <tbody>

                 <tr>

                     <th scope="row_1"><label for="first_name">신청자<span class="required_star">*</span></label></th>

                     <td width="80%"><input id="nameinput" name="first_name" type="text" class="ipt" size="30" maxlength="50" placeholder="성함 / 직책을 입력해주세요." required=""></td>

                     </tr>

                 <tr class="multi_select">

                    <th scope="row_1"><label for="qna">문의 내용 <span class="small_p">[복수선택가능]</span><span class="required_star">*</span></label></th>

                    <td colspan="2">

                            <input type="checkbox" name="qna[]" class="check" value="사업제휴" id="test1"><label for="test1">사업제휴</label> <span style="margin-left:10px;display:inline-block;"></span>

                            <input type="checkbox" name="qna[]" class="check" value="방송/협찬" id="test2"><label for="test2">방송/협찬</label><span style="margin-left:10px;display:inline-block;"></span>

                            <input type="checkbox" name="qna[]" class="check" value="유통/판매" id="test3"><label for="test3">유통/판매</label><span style="margin-left:10px;display:inline-block;"></span>

                            <input type="checkbox" name="qna[]" class="check" value="홍보/마케팅" id="test4"><label for="test4">홍보/마케팅</label><span style="margin-left:10px;display:inline-block;"></span>

                            <input type="checkbox" name="qna[]" class="check" value="제안" id="test5"><label for="test5">제안</label><span style="margin-left:10px;display:inline-block;"></span>


                            <input type="checkbox" name="qna[]" class="check" value="프로모션" id="test6"><label for="test6">프로모션</label><span style="margin-left:10px;display:inline-block;"></span>

                            <input type="checkbox" name="qna[]" class="check" value="대량구매" id="test7"><label for="test7">대량구매</label><span style="margin-left:10px;display:inline-block;"></span>

                            <input type="checkbox" name="qna[]" class="check" value="오프라인 미팅요청" id="test8"><label for="test8">오프라인 미팅요청</label><span style="margin-left:10px;display:inline-block;"></span>

                        </td>

                    </tr>

                 <tr>

                      <th scope="row_1"><label for="phone_num">연락처 <span class="required_star">*</span></label></th>

                      <td width="80%"><input id="phoneinput" name="phone_num" type="text" class="ipt" size="30" maxlength="50" placeholder="연락처를 입력해주세요." required=""></td>

                      </tr>

                  <tr>

                     <th scope="row"><label for="email">이메일 주소  <span class="required_star">*</span></label></th>

                     <td><input id="mailinput" name="email" type="text" class="ipt" size="30" maxlength="80" placeholder="올바른 이메일 주소를 입력해주세요." required=""></td>

                     </tr>

                  <tr>

                     <td height="40" colspan="2" style="text-align:center"><input type="submit" value="문의하기" class="btn_submit"><input name="재설정" type="reset" value="다시작성" class="btn_submit"></td>

                     </tr>

                     <tr>

                         <td>

                             <input type="checkbox" name="chkAgree" id="w_check" value="1" class="chkBox" required="">

                            <label for="w_check"><a href="/web/renewal2016/customer/privacy_info.asp" target="_blank"><u>개인정보처리방침</u></a>에 동의 하시겠습니까?</label>

                         </td>

                     </tr>

               </tbody>

               </table>

            </form>

         </div>

      </div></p>

<p>

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

답변 1개

채택된 답변
+20 포인트
해피정
4년 전

                                                                                   

 

를 이렇게 변경하세요

 

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

답변에 대한 댓글 1개

굼떠
4년 전
감사합니다!

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

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

로그인