/ Published in: PHP

Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<?php function cleanInput($input) { '@<script[^>]*?>.*?</script>@si', // Strip out javascript '@<[\/\!]*?[^<>]*?>@si', // Strip out HTML tags '@<style[^>]*?>.*?</style>@siU', // Strip style tags properly '@<![\s\S]*?--[ \t\n\r]*>@' // Strip multi-line comments ); return $output; } ?> <?php function sanitize($input) { foreach($input as $var=>$val) { $output[$var] = sanitize($val); } } else { } $input = cleanInput($input); } return $output; } ?>
URL: http://css-tricks.com/snippets/php/sanitize-database-inputs/
Comments
