How to prevent against XSS and SQL injection [duplicate]
问题 This question already has answers here : How can I sanitize user input with PHP? (17 answers) Closed 6 years ago . i want to check my data from the user for XSS and SQL injection and this is how i tried if (isset($_GET['membernumber'])) { $mem = htmlentities($_GET['membernumber']); $memberparamter = cleanData($mem); } But which method is the best/correct way to check? Method 1 function cleanData($data) { $data=mysql_real_escape_string($data); $data=trim($data); $data=stripcslashes($data);