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

폼메일에 개인정보 체크시에만 전송 채택완료

현현 1년 전 조회 730

https://sir.kr/g5_skin/10486 

덕서리 님 것으로 폼메일을 적용하였습니다! 

폼에 개인정보 동의 내용을 추가한 후 체크 시에만 전송이 되고, 체크가 안될 시 전송이안되고 경고창이 뜨도록 하고싶습니다 ㅜㅜ html부분에 체크박스는 추가해놓았는데  php 부분에는  어떤 코드를 추가하고 수정해야할까요... 도와주세요...

 

</strong></p>

<p><form name="contactform" method="post" action="send.php"></p>

<p><table></p>

<p><tr></p>

<p><th scope="row"></p>

<p><label for="first_name">이름</label></th></p>

<p><td width="100%"></p>

<p> </p>

<p><input name="first_name"  type="text" class="ipt" style="height:20px" size="30" maxlength="50" required ></p>

<p></td></p>

<p></tr></p>

<p> </p>

<p><tr></p>

<p><th scope="row"></p>

<p><label for="email">이메일 주소</label></th></p>

<p><td></p>

<p><input name="email"  type="text" class="ipt" style="height:20px" size="30" maxlength="80" required ></p>

<p></td></p>

<p></tr></p>

<p><tr></p>

<p><th scope="row"></p>

<p><label for="telephone">연락처</label></th></p>

<p><td></p>

<p><input name="telephone"  type="text" class="ipt" style="height:20px" size="30" maxlength="30" required ></p>

<p></td></p>

<p></tr></p>

<p><tr></p>

<p><th scope="row"></p>

<p><label for="comments">문의내용</label></th></p>

<p><td height="170" valign="bottom"></p>

<p>  <textarea  name="comments" cols="50" rows="10" style="width:95%" required ></textarea></td></p>

<p></tr></p>

<p><tr></p>

<p><td height="40" colspan="2" style="text-align:center"></p>

<p><input type="submit" value="문의하기" class="btn_submit"></p>

<p></tr></p>

<p></table></p>

<p></form></p>

<p><div class="agree-box"></p>

<p>  <h3>*개인정보 수집 및 이용에 관한 안내</h3></p>

<p>  <ul></p>

<p>    <li>''는 문의하는 기업 및 개인을 대상으로 아래와 같이 개인정보를 수집하고 있습니다.</li></p>

<p>    <li>1. 수집 개인정보 항목 : 성명, 메일주소, 전화번호, 회사명, 홈페이지 주소, 팩스번호, 주소</li></p>

<p>    <li>2. 개인정보의 이용기간 : 모든 검토가 완료된 후 3개월간 이용자의 조회를 위하여 보관하며, 이후 해당정보를 지체 없이 파기합니다.</li></p>

<p>    <li>3. 그 밖의 사항은 개인정보취급방침을 준수합니다.</li></p>

<p>  </ul></p>

<p>  <label><input type="checkbox"  name="U_checkAgreement" value="" id="U_checkAgreement">개인정보 제3자 제공에 동의합니다.(미동의시 신청불가)</label></p>

<p></div></p>

<p><strong>

 

 

 

 

</strong></p>

<p><?php</p>

<p>if(isset($_POST['email'])) {</p>

<p>     </p>

<p>   </p>

<p>  $email_to = "hyun@storyzine.com";</p>

<p>  $email_subject = "[폼메일] 문의사항입니다.";</p>

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

<p> </p>

<p>     </p>

<p>     </p>

<p>    function died($error) {</p>

<p>        // your error code can go here</p>

<p>        echo "<script> alert('메일발송을 실패하였습니다.');";</p>

<p>    echo "history.go(-1);";</p>

<p>    echo "</script>";</p>

<p>        die();</p>

<p>    }</p>

<p>     </p>

<p>    // validation expected data exists</p>

<p>    if(!isset($_POST['first_name']) ||</p>

<p>        !isset($_POST['email']) ||</p>

<p>        !isset($_POST['telephone']) ||</p>

<p>        !isset($_POST['comments'])) {</p>

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

<p>    }</p>

<p>     </p>

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

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

<p>    $telephone = $_POST['telephone']; // not required</p>

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

<p>     </p>

<p>    $error_message = "";</p>

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

<p>  if(!preg_match($email_exp,$email_from)) {</p>

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

<p>  }</p>

<p>   </p>

<p>  if(strlen($comments) < 2) {</p>

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

<p>  }</p>

<p>  if(strlen($error_message) > 0) {</p>

<p>    died($error_message);</p>

<p>  }</p>

<p>    $email_message = "";</p>

<p>     </p>

<p>    function clean_string($string) {</p>

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

<p>      return str_replace($bad,"",$string);</p>

<p>    }</p>

<p>     </p>

<p>    $email_message .= "이름 : ".clean_string($first_name)."\n\n";</p>

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

<p>    $email_message .= "연락처 : ".clean_string($telephone)."\n\n";</p>

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

<p>



 </p>

<p>     </p>

<p>     </p>

<p>// create email headers</p>

<p>$headers = 'From: '.$email_from;</p>

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

<p> </p>

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

<p>?></p>

<p> </p>

<p><!-- include your own success html here --></p>

<p> </p>

<p><script></p>

<p> </p>

<p>   </p>

<p>alert ("메일이 발송되었습니다.\n빠른 시일안에 답변드리겠습니다.");</p>

<p>location.href='../';</p>

<p>



 </p>

<p></script></p>

<p> </p>

<p><?php</p>

<p>}</p>

<p>?></p>

<p><strong>

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

답변 1개

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

</p>

<p><!-- <form name="contactform" method="post" action="send.php"> --></p>

<p><form name="contactform" method="post" action="send.php" id="contactform"></p>

<p>

 

</p>

<p><!-- <input type="checkbox"  name="U_checkAgreement" value="" id="U_checkAgreement"> --></p>

<p><input type="checkbox"  name="U_checkAgreement" value="" id="U_checkAgreement" form="contactform" required></p>

<p>

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

답변에 대한 댓글 1개

현현
1년 전
도움주셔서 감사합니다 ㅜㅜㅜㅜ

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

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

로그인