/ Published in: PHP
                    
                                        Sanitize database inputs
                
                            
                                Expand |
                                Embed | Plain Text
                            
                        
                        Copy this code and paste it in your HTML
 function cleanInput($input) { $search = array( '@<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 ); $output = preg_replace($search, '', $input); return $output; } ?> <?php function sanitize($input) { foreach($input as $var=>$val) { $output[$var] = sanitize($val); } } else { } $input = cleanInput($input); } return $output; }
Comments
                    Subscribe to comments
                
                