In php you need to implement this one for secure input for MySQL. This one also help to know you about your question - How to Write Secure PHP Code to Prevent Malicious Attacks.
Sanitizing data means Remove any illegal character from the data.
function sanitize_input($string) {
if (is_string($string)) {
return trim(sanitize_string(stripslashes($string)));
} elseif (is_array($string)) {
reset($string);
while (list($key, $value) = each($string)) {
$string[$key] = sanitize_input($value);
}
return $string;
} else {
return $string;
}
}
function sanitize_string($string) {
$patterns = array ('/ +/','/[<>]/');
$replace = array (' ', '_');
return preg_replace($patterns, $replace, trim($string));
}
Conclusion
However, only writing codes securely isn’t going to be enough. Apart from that, you have to integrate a higher form of security in your hardware and software too. If you want to know more about it, make sure to visit website today!
Write a comment