0
문의 양식에 잘못된 단어를 필터링하는 데 문제가 있습니다. 단어의 첫 문자를 제외한 모든 메시지를 제거합니다. 도움이 되었습니까? 아래 PHP 기반 문의 양식에 단어 필터링 필터링
단지 정보<?php
$error = '';
if(!empty($_POST['username'])) $username = $_POST['username'];
if(!empty($_POST['email'])) $email = $_POST['email'];
if(!empty($_POST['subject'])) $subject = check($_POST['subject']);
if(!empty($_POST['message'])) $msg = filter($_POST['message']);
을 받고 이것이 내가 나쁜 단어를 제거하고 옵션 아래 그들에게
$bad_words = array(
'word1' => 'gosh',
'word2' => 'darn',);
function filter($matches) {
global $bad_words;
$replace = $bad_words[$matches[0]];
return !empty($replace) ? $replace : $matches[0];
}
검사 드롭을 대체하기 위해 사용하려고하고 있어요 기능이없는 것입니다 특정 과목의 이메일 전송을 허용하십시오.
function check($str){
global $error;
if ($str == 'Mean Spirited Comment'){
$error = 'You sent a Mean-Spirited Comment';
} else if ($str =='Political Comment'){
$error = 'You sent a Political Comment';
}
return $str;
}
장소 정보 및 전송
$to = '[email protected]';
if (!empty($subject) && !empty($msg) && !empty($email) && !empty($username)){
if ($error == ''){
mail($to, $subject, $msg, 'From:' . $email);
} else {
print $error;
}
}
?>
대답이 없지만'empty()'대신'isset()'을 사용해야합니다. 또한'global'을 사용하지 마십시오. – PeeHaa