Sanitize MySQL Inputs

Prepare the data so that when it gets added to your SQL query it doesn’t break the server ( Defence SQL injection attack ).
When a form has been submitted via GET or POST all data is stored in the global array:
$_GET , $_POST, $_REQUEST and $_COOKIE.
<?php
function sanitize(&$t){
$t = array_map(‘trim’, $t);
$t = array_map(’stripslashes’, $t);
$t = array_map(‘mysql_real_escape_string’, $t);
}function sanitize_input() {
sanitize($_POST);
sanitize($_GET);
sanitize($_REQUEST);
sanitize($_COOKIE);
}sanitize_input();
?>
sanitize_input() will check all global arrays like $_GET, $_POST, $_REQUEST, $_COOKIE, allow only valid data!







