Skip to content

Instantly share code, notes, and snippets.

@sunriax
Created July 15, 2017 17:52
Show Gist options
  • Save sunriax/fdc4b72f16b0c1fdbe884bc1fdf951bf to your computer and use it in GitHub Desktop.
Save sunriax/fdc4b72f16b0c1fdbe884bc1fdf951bf to your computer and use it in GitHub Desktop.
Protection of your PHP environment
<?PHP
// If you GET/POST/REQUEST variables from extern
// Do not forget to protect them from overriding
if( !isset($_GET["test1"]) &&
!isset($_POST["test2"]) &&
!isset($_REQUEST["test3"])) { $test1 = htmlentities($_GET["test1"]);
$test2 = htmlentities($_POST["test2"]); 
$test3 = htmlentities($_REQUEST["test3"]); }
// If you use extern variables in MYSQL please
// do not forget to protect the query
$test1_escaped = mysqli_real_escape_string($_SOCKET, $test1);
$test2_escaped = mysqli_real_escape_string($_SOCKET, $test2);
$test3_escaped = mysqli_real_escape_string($_SOCKET, $test3);
$query = mysqli_query($_SOCKET, "SELECT id, name, text FROM data WHERE id = '".$test1."' .... ORDER BY id");
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment