Skip to content

Instantly share code, notes, and snippets.

@stevesohcot
Created November 14, 2021 18:46
Show Gist options
  • Select an option

  • Save stevesohcot/66cf528d606e6449f59e6479b1b332b5 to your computer and use it in GitHub Desktop.

Select an option

Save stevesohcot/66cf528d606e6449f59e6479b1b332b5 to your computer and use it in GitHub Desktop.
PHP SQL Injection Prevention - function to sanitize
<?php
function quote_smart($db_connection, $value) {
if( get_magic_quotes_gpc() )
$value = stripslashes( $value );
$value = mysqli_real_escape_string($db_connection, $value );
$value = strip_tags($value);
$value = htmlspecialchars($value);
$value = trim($value);
return $value;
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment