폼메일 발송이 안되요. 도와주세요. 채택완료
form.php 파일
</p>
<p><form id="form1" name="contactform" class="container" method="post" action="send.php">
<table>
<tr>
<td class="type_wrap" colspan="2">
<input id="type1" name="type1" type="checkbox" value="전화 상담"><label for="type1">전화 상담</label>
<input id="type2" name="type2" type="checkbox" value="이메일 상담"><label for="type2">이메일 상담</label>
</td>
</tr>
<tr>
<td>
<input id="name" name="name" type="text" maxlength="40" placeholder="상호명"> <!-- name 부분이 form_send.php에서 $name 으로 전송된다. -->
</td>
<td>
<input id="name2" name="name2" type="text" maxlength="40" placeholder="담당자">
</td>
</tr>
<tr>
<td>
<input id="number" name="number" type="text" maxlength="40" placeholder="연락처">
</td>
<td>
<input id="email" name="email" type="text" maxlength="100" placeholder="이메일">
</td>
</tr>
<tr>
<td colspan="2">
<textarea id="question" name="question" type="text" maxlength="400" placeholder="문의 내용"></textarea>
</td>
</tr>
<tr>
<td class="agree_wrap" colspan="2">
<input type="checkbox" name="agree" id="agree" value="개인정보 취급 동의"><label for="agree">개인정보 수집동의</label>
</td>
</tr>
</table>
<input type="submit" id="submit" value="문의 하기" onclick="form_Check();" ></p>
<p> <script type="text/javascript">
function form_Check(){
if(form1.name.value == ''){
alert("상호명을 입력해주십시오.");
form1.name.focus();
return;
}
if(form1.name2.value == ''){
alert("담당자를 입력해주십시오.");
form1.name.focus();
return;
}
if(form1.number.value == ''){
alert("연락처를 입력해주십시오.");
form1.hp1.focus();
return;
}
if(form1.email.value == ''){
alert("이메일주소를 입력해주십시오.");
form1.email.focus();
return;
}
if(form1.question.value == ''){
alert("문의사항을 입력해주십시오.");
form1.email.focus();
return;
}
var agree = document.getElementById("agree");
if(!agree.checked) {
alert("개인정보수집에 동의 하셔야 합니다.");
agree.focus();
return false;
}
if(!confirm('폼메일을 전송하겠습니까?')) return;
}
</script>
</form></p>
<p>
send.php 파일
</p>
<p><meta charset="utf-8">
<?php
if(isset($_POST['email'])) {
$email_to = "muto55@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('Failed to send mail.');";
echo "history.go(-1);";
echo "</script>";
die();
}</p>
<p>
// input추가시 추가 start
if(!isset($_POST['type1']) || //전화 상담
!isset($_POST['type2']) || //이메일 상담
!isset($_POST['name']) || //상호명
!isset($_POST['name2']) || //담당자
!isset($_POST['number']) || //연락처
!isset($_POST['email']) || //이메일
!isset($_POST['question'])) {
died('We are sorry, but there appears to be a problem with the form you submitted.');
}
// input추가시 추가 start
$type1 = $_POST['type1']; // required
$type2 = $_POST['type2']; // required
$name = $_POST['name']; // required
$name2 = $_POST['name2']; // required
$number = $_POST['number']; // required
$email_from = $_POST['email']; // required
$question = $_POST['question']; // required</p>
<p> $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);
}
//* input추가시 추가 start
$email_message .= "상호명 : ".clean_string($name)."\n\n";
$email_message .= "담당자 : ".clean_string($name2)."\n\n";
$email_message .= "연락처 : ".clean_string($number)."\n\n";
$email_message .= "이메일 : ".clean_string($email_from)."\n\n";
$email_message .= "문의 내용 : ".clean_string($question)."\n\n";
$email_message .= "상담 방법 : ".clean_string($type1)."\n\n";
$email_message .= "상담 방법 : ".clean_string($type2)."\n\n";</p>
<p>
// 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 ("빠른 시일 내에 답변을 보내드리겠습니다.");
location.href='index.php';//돌아갈 폼메일 링크로</p>
<p></script>
<?php
}
?></p>
<p>
댓글을 작성하려면 로그인이 필요합니다.
답변 2개
답변을 작성하려면 로그인이 필요합니다.
로그인전체 질문 목록
채택
채택
답변대기
답변대기
채택
채택
채택
채택
채택
채택
채택
채택
답변대기
채택
답변대기
답변대기
채택
채택
답변대기
채택