<?php
if ( isset( $_POST ) )
$postArray = &$_POST ; // 4.1.0 or later, use $_POST
else
$postArray = &$HTTP_POST_VARS ; // prior to 4.1.0, use HTTP_POST_VARS
foreach ( $postArray as $sForm => $value )
{
$postedValue = htmlspecialchars( stripslashes( $value ) ) ;
?>
<tr>
<td valign="top" nowrap><b><?=$sForm?></b></td>
<td width="100%"><?=$postedValue?></td>
</tr>
<?php
}
?>
本文介绍了一种使用PHP处理表单数据的方法,通过结合htmlspecialchars和stripslashes函数确保了数据的安全性和整洁性。该方法适用于不同版本的PHP,并且能够有效地防止XSS攻击和SQL注入等安全风险。
1151

被折叠的 条评论
为什么被折叠?



