채택완료

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

Copy
<meta charset="utf-8"><?phpif(isset($_POST['telephone'])) {         	$email_to = "zeumad@naver.com";	$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개 / 댓글 1개

채택된 답변
+20 포인트

function died($error){

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

}

 

died("경고창내용");

답변에 대한 댓글 1개

dart님 덕분에 깨끗히 해결되었어요. 감사합니다.

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

🐛 버그신고