目前我使用这个策略:
提交使用发送HTML格式或数据后jQuery的$.get()
或$.post()
我需要知道什么来,然后在应用逻辑的基础。
想,我有$_POST['username'],
$_POST['password']
和$_POST['login_submit_button']
。 在我的处理用脚本文件,我这样做:
if(isset($_POST['login_submit_button']) && isset($_POST['username']) && $_POST['username'] != "" && isset($_POST['password']) && $_POST['password'] != "") {
// calling a common function safe_vars() which does
// mysql_real_escape_string(stripslashes(trim($any_variable_need_to_become_safe)))
// and now using the above variables for different purposes like
// calculation, insertion/updating old values in database etc.
}
我知道这一切的逻辑是错误的或有严重的问题,所以我想一个更安全和完美的解决方案,而不是这个。我欢迎在我的策略中找出漏洞和严重的安全漏洞。如果答案更具说明性,这个问题也可以帮助其他人,这可以是信息丰富的社区维基。
检查'的strlen($ _ POST [ '用户名'])> 0'是更有效,因为你不会有检查是否存在价值或不再是。 – Pieter888
或尝试'&&(!empty($ _ POST ['username']))&& ...' – Neograph734
与!empty($ _ POST ['username'])一样。如果没有设置$ _POST ['username'],将会发出通知(对于emtpy和strln函数,但是我猜你不会在你的项目在线时显示通知错误) – Mohammer