1702208017

Sanitize fields


When accepting user input for redisplay, and particularly if it will be inserted into a database, it’s important that you sanitize the input to remove any malicious attempts at hijacking your server, or otherwise injecting unwanted MySQL commands, HTML, or JavaScript. ## the function ```php function SanitizeString($string){ $string = strip_tags($string); return htmlentities($string); } function MysqlSanitizeString($string){ if(get_magic_quotes_gpc()) $string = stripslashes($string); $string = SanitizeString($string); return mysql_real_escape_string($string); } ``` ### About the Recipes These recipes take a string and sanitize it for reuse on your web site and/or in a MySQL database. They require this argument: >  **$string**   A string to be sanitized.

(0) Comments

Welcome to Chat-to.dev, a space for both novice and experienced programmers to chat about programming and share code in their posts.

About | Privacy | Terms | Donate
[2024 © Chat-to.dev]