그누보드5 폼메일 스킨 적용 채택완료
https://sir.kr/g5_skin/10486?sfl=wr_subject&stx=%ED%8F%BC%EB%A9%94%EC%9D%BC
안녕하세요, 폼메일 스킨 경로와 관련해 오류가 생겨 여쭤봅니다.
위 링크의 스킨을 다운받아 감사하게도 사용 중입니다.
3개의 파일을 모두 theme/내가만든테마 폴더에 넣었을 때는 정상적으로 작동합니다.
(send.php=보내는파일/formmail_me.php=메일양식/sample.php=폼메일을 포함한 일반페이지)
지금 제가 원하는 부분은 짧은 주소 사용 때문에 일반페이지 모두를 theme/내가만든테마/doc폴더에 넣어 사용하고 싶습니다. (즉, 폼메일 파일을 doc폴더에 넣고 싶습니다.)
그래서 sample.php파일을 doc폴더에 넣었더니 다 정상적으로 뜨는데 보내기 버튼을 누르는 순간 전송이 되지 않고, 페이지를 표시할 수 없습니다 라고 뜹니다.
send에 관련된 경로가 잘못된 거 같아서 찾아보고 있는데, 도저히 모르겠어서요.
혹시 선생님들께 조언 부탁드려도 될까요?
send.php
<meta charset="utf-8">
<?php
if(isset($_POST['email'])) {
$email_to = "내 메일 주소";
$email_subject = "[폼메일] 문의사항입니다.";
$email_subject = '=?UTF-8?B?'.base64_encode($email_subject).'?=';
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['questionType']) ||
!isset($_POST['company_name']) ||
!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.');
}
$questionType = $_POST['questionType']; // required
$company_name = $_POST['company_name']; // required
$first_name = $_POST['first_name']; // required
$email_from = $_POST['email']; // required
$telephone = $_POST['telephone']; // not required
$comments = $_POST['comments']; // 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.<br />';
}
if(strlen($comments) < 2) {
$error_message .= 'The Comments you entered do not appear to be valid.<br />';
}
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($questionType)."\n\n";
$email_message .= "회사명 : ".clean_string($company_name)."\n\n";
$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;
// 제목이 깨질경우 아래 캐릭터셋 적용
@mail($email_to, $email_subject, $email_message, $headers);
?>
<!-- include your own success html here -->
<script>
alert ("메일이 발송되었습니다.\n빠른 시일안에 답변드리겠습니다.");
window.location.href='/'; //메인페이지로 돌아가기
</script>
<!-- 경고창 뜨기 -->
<?php
}
?>
sample.php (doc폴더에 들어가 있는 파일)
<?php
include_once('../../../common.php');
$g5['title'] = '고객센터_문의하기';
$pageNum = "1";
include_once(G5_PATH.'/head.php');
?>
<div>
<? include_once(G5_PATH."/theme/bsculture/formmail_me.php") ?>
</div>
<?php
include_once(G5_PATH.'/tail.php');
?>
답변 1개
/theme/bsculture/formmail_me.php
<form action="send.php"> 있다면 적절하게 수정하시고 자바스크립트로 submit할때 폼검증을한다면 해당 코드중에 전송 URL이 있을수 있습니다 해당부분을 적절하게 수정하세요
답변에 대한 댓글 3개
폴라베어님 덕분에 해결했습니다.
비 많이 오는데 조심하시고 좋은 하루 보내세요!
댓글을 작성하려면 로그인이 필요합니다.
답변을 작성하려면 로그인이 필요합니다.
로그인
제가 깜빡하고 formmail.php 내용을 올리지 않았네요, 죄송합니다. 제가 봤을 때는 어떤 점이 잘못되었는지 잘 모르겠는데 괜찮으시다면 한번 봐주시겠어요?
(너무 길어 부분만 코드 썼습니다ㅠㅠ)
[code]
<!-- 메일 폼 내용 시작 -->
<form name="contactform" method="post" action="send.php" id="mail_form">
</form>
<script type="text/javascript">
$(document).ready(function(){
$(".btn_submit").on("click",function(){
var questionType = $(".questionType").val();
var company_name = $(".company_name").val();
var first_name = $(".first_name").val();
var email = $(".email").val();
var telephone = $(".telephone").val();
var comments = $(".comments").val();
if(questionType==""){
alert("문의유형을 선택해주세요.");
questionType.focus();
}
if(company_name==""){
alert("회사이름을 작성해주세요.");
company_name.focus();
}
if(first_name==""){
alert("이름을 작성해주세요.");
first_name.focus();
}
if(email==""){
alert("메일주소를 작성해주세요.");
email.focus();
}
// 원하는 문구의 alert창 뜨게 하기
var mailformat = /^[0-9a-zA-Z]([-_.]?[0-9a-zA-Z])*@[0-9a-zA-Z]([-_.]?[0-9a-zA-Z])*.[a-zA-Z]{2,3}$/i; // 이메일이 적합한지 검사할 정규식
if(mailformat.test(email) === false) {
alert("잘못된 이메일 형식입니다.");
return;
}
if(telephone==""){
alert("전화번호를 작성해주세요.");
telephone.focus();
}
if(comments==""){
alert("내용을 작성해주세요.");
comments.focus();
}
document.getElementById("mail_form").submit();
});
});
</script>
[/code]