HerbRodenhaber;10988403 wrote:question ... i dont see why you would want to validate the $location ... as changing the location variable to something that doesnt exist gets you nowhere it would just not load the page ... how does this help anyone ?? what am i missing here ...
short answer:
always assume user input is bad -meaning "error-prone" and/or "evil".
always validate & sanitize your inputs.
to elaborate:
What if you have some page on your site that is not supposed to be publicly available? Say you have a password-protected directory - your visitor can't access it without the password. BUT, if they enter the correct URL into your form, that page will be displayed - completely circumventing your password.
Take it even further: there are configuration files and CGI scripts, and maybe other stuff, on your web server. Normally, it's all "above" the web root - it's inaccessible via the internet - in order to keep the server safe. With your form, a visitor could enter a relative URL (like [font=monospace]/../CGI-bin/some-script-or-whatever.cgi[/font]), and gain access to that file.
Or, a simpler concern: you're creating an error where there doesn't need to be one.
[font=monospace]Warning: include(nonexistent.php) [function.include]: failed to open stream: No such file or directory in /opt/lampp/htdocs/sand/eval.php(9) : line xx
Warning: include() [function.include]: Failed opening 'nonexistent.php' for inclusion (include_path='.:/opt/lampp/lib/php') in /opt/lampp/htdocs/sand/eval.php(9) : line xx[/font]
In fact, throwing such an error on purpose could be the first step of examining your server setup for possible attack points.
SO,
always validate & sanitize your inputs.