php url variable xss sanitize

Solutions on MaxInterview for php url variable xss sanitize by the best coders in the world

showing results for - "php url variable xss sanitize"
Bruno
10 Oct 2018
1
2<?php
3// It is important to sanitize
4// input! Otherwise, a bad actor
5// could enter '<script src="evilscript.js"></script>'
6// in a URL parameter. Assuming you echo it, this
7// would inject scripts in an XSS attack.
8//
9// The solution:
10$NAME = $_GET['NAME'];
11// Bad:
12echo $NAME;
13// that one is vulnerable to XSS
14// Good:
15echo htmlspecialchars($NAME);
16// Sanitizes input thoroughly.
17?>
18
19