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

폼메일 이름/연락처만 사용하고 싶어요.. 채택완료

춘여사 7년 전 조회 3,358

</p>

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

<?php

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

     

    

    $email_to = "hukddu24@naver.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['email']) ||

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

        !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

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

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

    $comments = $_POST['comments']; // not 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($first_name)."\n\n";

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

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

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

     

     

// create email headers

$headers = 'From: '.$email_from;

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

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

?>

 

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

 

<script>

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

location.href='../';

</script>

 

<?php

}

?></p>

<p>

 

관련링크의 폼메일을 사용하고 있는데..

이름하고 연락처만 쓰고 싶은데 뭘 지워야 할까요 ㅠㅠㅠㅠ

저녁부터 지금까지 붙잡다가 답답한 마음에 글을 남겨요 ㅠㅠㅠ

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

답변 3개

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

이름/연락처 제외한 정보에 관련 된 코드는 다 삭제 했는데

오류날 수도 있으니 테스트 해보셔요.

 

</p>

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

<?php

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

<p>

$email_to = "<span class="privacy_hidden">*** 개인정보보호를 위한 이메일주소 노출방지 ***</span>";

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

}</p>

<p>// validation expected data exists

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

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

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

}</p>

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

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

<p>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($telephone)."\n\n";

?></p>

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

<p><script>

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

location.href='../';

</script></p>

<p><?php

}

?></p>

<p>

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

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

M
7년 전

</p>

<p>// create email headers

$headers = 'From: '.$email_from;

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

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

<p>

 

위 코드는 다시 추가해서 넣어주세요

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

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

7년 전

소중한 답변 감사합니다 ㅠㅠㅠ

죄송하지만... 저렇게 했더니 메일이 안와요 ㅠㅠㅠ  

 

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

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

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

로그인