你好! 我只是想知道如何安全是这个脚本联系形式我只是做? 我的老师对我唠叨很久以前,当我做了我的contactforms。
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这不是我出什么。