오류문구가 제대로 나오지 않습니다...

매출이 오르면 내리는 수수료! 지금 수수료센터에서 전자결제(PG)수수료 비교견적 신청해 보세요!
오류문구가 제대로 나오지 않습니다...

QA

오류문구가 제대로 나오지 않습니다...

본문


<meta charset="utf-8">
<?php
if(isset($_POST['telephone'])) {
     
    
	$email_to = "*** 개인정보보호를 위한 이메일주소 노출방지 ***";
	$email_subject = "[폼메일] 카카오톡 DB입니다.";
	$email_subject = '=?UTF-8?B?'.base64_encode($email_subject).'?=';
 
    function died($error) 
		{echo "<script> alert('메일발송을 실패하였습니다.');";
		echo "history.go(-1);";
		echo "</script>";
        die();}
     
    
    if (!isset($_POST['first_name']) ||
        !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'];
    $telephone = $_POST['telephone'];
    $comments = $_POST['comments'];
     
    $error_message = "";
    $telephone_exp = '/^[0-9]{9,11}$/';
  if(!preg_match($telephone_exp,$telephone)) 
	{$error_message .= '-를 제외한 9-11자리의 연락처를 입력해 주십시오.';}
    
  if(strlen($comments) < 1) 
	{$error_message .= '문의사항을 입력해 주십시오.';}
  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($telephone)."\n\n";
    $email_message .= "문의사항 : ".clean_string($comments)."\n\n";
	
// create email headers
$headers = 'From: '.$email_from;
// 제목이 깨질경우 아래 캐릭터셋 적용
 
@mail($email_to, $email_subject, $email_message, $headers);  
?>
 
<!-- include your own success html here -->
 
<script>
alert ("메일이 발송되었습니다.\n빠른 시일안에 답변드리겠습니다.");
location.href='';
</script>
 
<?php
}
?>

 

메일은 잘 전송이 되는데

오류메세지가 상황별로 나오지가 않습니다...

연락처 미입력시

-를 제외한 9-11자리의 연락처를 입력해 주십시오. 

라는 문구가 나오고 싶게 하고싶은데 어떻게 해야되나요?

이 질문에 댓글 쓰기 :

답변 1

function died($error){

        echo "<script> alert('".$error."');";
        echo "history.go(-1);";
        echo "</script>";
        die();

}

 

died("경고창내용");

답변을 작성하시기 전에 로그인 해주세요.
전체 124,276 | RSS
QA 내용 검색

회원로그인

(주)에스아이알소프트 / 대표:홍석명 / (06211) 서울특별시 강남구 역삼동 707-34 한신인터밸리24 서관 1404호 / E-Mail: admin@sir.kr
사업자등록번호: 217-81-36347 / 통신판매업신고번호:2014-서울강남-02098호 / 개인정보보호책임자:김민섭(minsup@sir.kr)
© SIRSOFT