Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

php url variable xss sanitize


<?php
// It is important to sanitize
// input! Otherwise, a bad actor
// could enter '<script src="evilscript.js"></script>'
// in a URL parameter. Assuming you echo it, this
// would inject scripts in an XSS attack.
//
// The solution:
$NAME = $_GET['NAME'];
// Bad:
echo $NAME;
// that one is vulnerable to XSS
// Good:
echo htmlspecialchars($NAME);
// Sanitizes input thoroughly.
?>

Source by www.php.net #
 
PREVIOUS NEXT
Tagged: #php #url #variable #xss #sanitize
ADD COMMENT
Topic
Name
5+1 =