Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * @Author: Alexis López (@AlexisThrasher)
- * @Title: Sanitize your POST data in PHP
- *
- * Example: Data received via POST method.
- * Array
- * (
- * [input1] => <a href = 'bad_site.php'>Link</a>
- * [input2] => 2
- * [input3] => Abc
- * [input4] => 'Hello'
- * [input5] => 0.343
- * )
- */
- $mysqli = new mysqli ('server', 'user', 'password', 'bd'); //Connection to MySQL
- $cleanedData = array(); //[] in PHP >= 5.3
- $cleanedData = array_map(function($data) use ($mysqli){
- return strip_tags($mysqli->real_escape_string($data));
- }, $_POST);
- echo implode(', ', $cleanedData); //Link, 2, Abc, \'Hello\', 0.343
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement