我有一个简单的PHP邮件程序脚本,该脚本从通过POST提交的表单中获取值并将其邮寄给我:
<?php $to = "me@example.com"; $name = $_POST['name']; $message = $_POST['message']; $email = $_POST['email']; $body = "Person $name submitted a message: $message"; $subject = "A message has been submitted"; $headers = 'From: ' . $email; mail($to, $subject, $body, $headers); header("Location: http://example.com/thanks"); ?>
如何清除输入内容?
用清理发布变量filter_var()。
filter_var()
这里的例子。喜欢:
echo filter_var($_POST['email'], FILTER_SANITIZE_EMAIL);