폼메일질문입니다.
본문
폼메일 질문입니다.
메일도 정상으로 들어오는데.
이 에러문구는 왜 나오는걸까요?ㅠㅠ
조언주시면 감사하겠습니다.
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge" charset="UTF-8">
<title>test</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
<?
header("content-type:text/html; charset=utf-8");
$subject = $_REQUEST["subject"];
$from_email = $_REQUEST['email'];
$from_name = $_REQUEST['name'];
$phone = $_REQUEST["phone"];
$content = $_REQUEST["content"];
$upfile = $_FILES['upfile']["name"];
$tmp_name = $_FILES['upfile']["tmp_name"];
$area = $_REQUEST["area"];
if ($upfile){
$file_name = attach_file($_FILES['upfile']['name'], $_FILES['upfile']['tmp_name']);
}
$body = "
<style>
/* 나눔고딕 */
@import url(http://fonts.googleapis.com/earlyaccess/nanumgothic.css);
html,body{margin:0px;padding:0px;width:100%;height:100%;font-family:'Nanum Gothic';letter-spacing:-0.5px;*letter-spacing:-1px;letter-spacing:-1px\9}
</style>
<div style='width:830px; height:auto; text-align:center; '>
<p style='padding:0; margin:10px 0 10px 0;'><img style='margin-top:10px' src='logo.png' width=\"150px;\" alt=''></p>
<p style='color:#333; font-size:20px; padding:0; margin:0;font-family:'><span style='font-family: 나눔고딕, NanumGothic, sans-serif;'>[".$area."] ".$subject."</span></p>
<br>
<div style=' display:block; width:770px; height:auto; border:1px solid #d5d5d5; text-align:left; padding:30px; margin-top:20px; color:#666; font-size:14px;font-family:'>
<span style='font-family: 나눔고딕, NanumGothic, sans-serif;'>
<p>이름 : ".$from_name."</p>
<p>이메일 : ".$from_email."</p>
<p>연락처 : ".$phone."</p>
<p> </p>
<p>문의내용 :".$content."</p>
<p></p> <br>
";
if($upfile){
$body .= "<p>첨부파일 : <a href=\"file.php?filename=".$file_name["name"]."\">".$file_name["name"]."</a></p>";
}
$body .="
</span>
</div>
<p style='padding:0; text-align:right; font-size:12px; padding-top:10px; color:#666;font-family:'><span style='color: rgb(255, 0, 0); font-family: 나눔고딕, NanumGothic, sans-serif;'>*</span><span style='font-family: 나눔고딕, NanumGothic, sans-serif;'> 본 메일은 발신전용으로 회신 되지 않습니다.</span></p>
</div>
";
function sendMail($EMAIL, $NAME, $mailto, $SUBJECT, $CONTENT){
//$EMAIL : 답장받을 메일주소
//$NAME : 보낸이
//$mailto : 보낼 메일주소
//$SUBJECT : 메일 제목
//$CONTENT : 메일 내용
$admin_email = $EMAIL;
$admin_name = $NAME;
$header = "Return-Path: ".$admin_email."\n";
$header .= "From: =?UTF-8?B?".base64_encode($admin_name)."?= <".$admin_email.">\n";
$header .= "MIME-Version: 1.0\n";
$header .= "X-Priority: 3\n";
$header .= "X-MSMail-Priority: Normal\n";
$header .= "X-Mailer: FormMailer\n";
$header .= "Content-Transfer-Encoding: base64\n";
$header .= "Content-Type: text/html;\n \tcharset=UTF-8\n";
$subject = "=?UTF-8?B?".base64_encode($SUBJECT)."?=\n";
$contents = $CONTENT;
$message = base64_encode($contents);
flush();
return mail($mailto, $subject, $message, $header);
}
sendMail($from_email,$from_name,"*** 개인정보보호를 위한 이메일주소 노출방지 ***",$subject,$body);
function attach_file($filename, $tmp_name){
// 서버에 업로드 되는 파일은 확장자를 주지 않는다. (보안 취약점)
$dest_file = '/two/file/'.str_replace('/', '_', $tmp_name);
move_uploaded_file( $_FILES['upfile']['tmp_name'], "file/".$_FILES['upfile']['name']);
$tmpfile = array("name" => $filename, "path" => $dest_file);
return $tmpfile;
}
?>
<script>
function file_down(file){
window.open("file.php?filename="+file);
}
</script>
</body>
</html>
<?
echo '<script>alert("접수되었습니다.");location.replace("/")</script>';
?>
답변 1
header("content-type:text/html; charset=utf-8");
php에서는 header 앞에 무언가가 출력이 되면 안 됩니다.
이걸 <!DOCTYPE html>보다 더 위에 올리세요.
<?
header("content-type:text/html; charset=utf-8");
?>
<!DOCTYPE html>
이하 생략
답변을 작성하시기 전에 로그인 해주세요.