묻고답하기
php4.2 에서 php5.2 업데이트 질문입니다
2014.06.12 17:11
http://3c-ole.co.kr/#filter=.contact
위사이트 폼메일에서 작성하고 전송 하면
이런 메세지가 뜹니다
Fatal error: Call to undefined function: filter_var() in /home/hosting_users/autumnlight/www/contact.php on line 9
카페24 호스팅쪽에 문의 햇더니 php5.2 버전에서 되는거라 하시는데
어떻게 하는지 잘 모르겠어서 문의드립니다!
소스 코드는 아래와 같습니다
<?php
if(!$_POST) exit;
function tommus_email_validate($email) { return filter_var($email, FILTER_VALIDATE_EMAIL) && preg_match('/@.+\./', $email); }
$name = $_POST['name']; $email = $_POST['email']; $comments = $_POST['comments'];
if(trim($name) == '') {
exit('<div class="error_message">You must enter your name.</div>');
} else if(trim($name) == 'Name *') {
exit('<div class="error_message">You must enter your name.</div>');
} else if(trim($email) == '') {
exit('<div class="error_message">Please enter a valid email address.</div>');
} else if(!tommus_email_validate($email)) {
exit('<div class="error_message">You have entered an invalid e-mail address.</div>');
} else if(trim($comments) == 'Comment *') {
exit('<div class="error_message">Please enter your message.</div>');
} else if(trim($comments) == '') {
exit('<div class="error_message">Please enter your message.</div>');
} else if( strpos($comments, 'href') !== false ) {
exit('<div class="error_message">Attention! Please leave links as plain text.</div>');
} else if( strpos($comments, '[url') !== false ) {
exit('<div class="error_message">Attention! Please leave links as plain text.</div>');
} if(get_magic_quotes_gpc()) { $comments = stripslashes($comments); }
$address = 'sample@naver.com';
$e_subject = 'You\'ve been contacted by ' . $name . '.';
$e_body = "You have been contacted by $name from your contact form, their additional message is as follows." . "\r\n" . "\r\n";
$e_content = "\"$comments\"" . "\r\n" . "\r\n";
$e_reply = "You can contact $name via email, $email";
$msg = wordwrap( $e_body . $e_content . $e_reply, 70 );
$headers = "From: $email" . "\r\n";
$headers .= "Reply-To: $email" . "\r\n";
$headers .= "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type: text/plain; charset=utf-8" . "\r\n";
$headers .= "Content-Transfer-Encoding: quoted-printable" . "\r\n";
if(mail($address, $e_subject, $msg, $headers)) { echo "<fieldset><div id='success_page'><h4>Email Sent Successfully.</h4><p>감사합니다! $name, 님의 메세지가 전달되었습니다.</p></div></fieldset>"; }