你好!我只是想知道我刚刚制作的这个联系人表单脚本有多安全?很久以前,当我制作联系表时,我的老师一直在唠叨我。
if($_SERVER['REQUEST_METHOD'] === 'POST'){
$myemail = "email@adress.com";
$name = $_POST['name'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$subject = $_POST['subject'];
$comments = $_POST['comments'];
if($name == 0 || !preg_match("/([\w\-]+\@[\w\-]+\.[\w\-]+)/", $email) || !preg_match("/^\d{2}(-\d{3}){2}(\d{2})?$/", $phone) || $subject == 0 || $comments == 0){
$error_message = 'Something was written wrong..';
} else {
$message = "Hello!
Your contact form has been submitted by:
Name: $name
E-mail: $email
Phone: $phone
Comments: $comments
End of message";
mail($myemail, $subject, $message);
$error_message = 'Your message was sent!';
}
}
有关如何使其安全的任何建议?
PS保护联系表和保护 php 联系表都适用于 WordPress,这不是我想要的。