Urlencode vs htmlentities
| From: | Mark Steudel | Date: | Tue, 06 Dec 2005 20:05:10 +0000 |
| Subject: | Urlencode vs htmlentities | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-226981@lists.php.net to get a copy of this message | ||
Lets say I have the following:
Current URL: http://www.domain.com/page.php?action=list
<http://www.domain.com/page.php?action=list&top=/page.php?action=list&id=3>
&top=/page.php?action=list&id=3
$top = $_SERVER['PHP_SELF'].'?'.$_SERVER['argv']['0']
Now I want to create a URL with a return link in it
<a
href="'.$_SERVER['PHP_SELF'].'?action=add&return='.$top.'">
Add
Something </a>
Should I use htmlentites on $top first?
Second let's say instead of constructing a link I want to use a header and
redirect someone
header("location: page.php?action=add&return=".$top );
So do I use urlencode here?
Lets say I have something that has been htmlentitied, and I want to use a
header command, do I htmlentitydecode and then urlencode?