确保PHP安全,不能违反的四条安全规则(9) $clean = preg_replace("![\][xX]([A-Fa-f0-9]{1,3})!", "",$input); return $clean;}?><form action="<?php echo $_SERVER['PHP_SELF'];?>" method="post"><p><label for="name">Name</label><input type="text" name="name" id="name" size="20" maxlength="40"/></p><input type="hidden" name="token" value="<?php echo $token;?>"/><p><input type="submit" name="submit" value="go"/></p></form>
这种技术是有效的,这是因为在 PHP 中会话数据无法在服务器之间迁移。即使有人获得了您的 PHP 源代码,将它转移到自己的服务器上,并向您的服务器提交信息,您的服务器接收的也只是空的或畸形的会话令牌和原来提供的表单令牌。它们不匹配,远程表单提交就失败了。