Is my escape function really safe? [duplicate]

拜拜、爱过 提交于 2019-12-12 03:07:33

问题


Possible Duplicate:
Best way to stop SQL Injection in PHP
The ultimate clean/secure function

My website was attacked via sql injection and now I need to improve it. I'm creating a function in PHP escape(), that returns the escaped version of a string. I'm not a hacker so please help me to improve my escape function. Here is the current version:

function escape($string){

    $string = stripslashes($string);
    $string = mysql_real_escape_string($string);
    $string = strip_tags($string);
    $string = str_replace('%','',$string);
    $string = str_replace('_','',$string);

    return $string;

}

My question is: is this hackable, if it is than how to fix it? Thanks!


回答1:


this function has absolutely nothing to do with safety.
it's barely protects you from some kinds of XSS injections. that's all.



来源:https://stackoverflow.com/questions/9957401/is-my-escape-function-really-safe

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!