I need to create a form whose action returns you to the same page - GET parameters are included. I think I can say something like:
echo '<form action="'.$_SERVER['SCRIPT_NAME'].'?'.$_SERVER['QUERY_STRING']. '" method="post">'
This seems to work, and testing the passing of several XSS attacks seems successful, since the output of QUERY_STRING seems to be URL encoded. However , the PHP documentation does not mention this, so I'm not sure I can trust this behavior.
Is it possible to use QUERY_STRING as I am above? If not, what can I do instead? Links to documentation will be appreciated.
Update switched to SCRIPT_NAME, just messed up which one was in order and what was bad in my head, thanks for catching me. action="" does a great job of my specific problem, but I'm still wondering if QUERY_STRING has been pre-processed, so it can be used safely or not, because there are other cases where you can reuse the query string, considering it safe for this.
source share