php - Request url on a save way -
i read url. www.domain.com?cookie=set&redirect=yes
now want use $ _server['request_uri']
not work strip_tags
, htmlspecialchars
.
also many read should watch xss.
does know how save url can used get?
$url = "http://'.$_server[http_host]$_server[request_uri]; $url = strip_tags($url);//doesnt work $url = htmlspecialchars($url);//doesnt work
thanks!
edit (doesnt work):
$url = "http://".$_server[http_host]."".$_server[request_uri]; $url = strip_tags($url); echo $url;
for example www.domain.com?cookie=set&redirect=yes
output => index.php?cookie=se%3cscript%3et&re%3cb%3ed%3c/b%3eirect=yes
this line
$url = "http://'.$_server[http_host]$_server[request_uri];
needs either
$url = "http://{$_server['http_host']}{$_server['request_uri']}";
or
$url = "http://".$_server['http_host'].$_server['request_uri'];
the way doing not concatenate data correctly.
issues line:
- your mixing quotes around protocol
"
open ,'
close - you not quoting
$_server
params e.g$_server['param']
- you not joining 2
$_server
vars you'll syntax error
Comments
Post a Comment