我的问题很简单:如果我在 HTML 表单中有一些带有 maxlength 标记的输入字段,我也必须通过 PHP 检查输入长度吗?
您应该这样做,因为任何人都可以“复制”您的表格并使用它。
服务器端检查比客户端更好。 (它是安全的)
例如,您的表格:
<form method='post' action='/pay.php'>
<input type='text' maxlength='10' name='addres'>
</form>
我可以轻松地做这样的事情:(并将其上传到一些免费服务器或类似的东西)
<form method='post' action='http://www.yourdomain.com/pay.php'>
<input type='text' name='addres'><!--no maxlength='10' for me-->
</form>
现在我有点“超越”你的限制了。
不过,您可以编辑您的pay.php
file:
$addres = clean_input($_POST['addres']); //A custom function to make sure it's a clean string
if(strlen($addres) > 100)
{
//Something weird
}
else
{
//We're good
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)