|
Newbie Notes:
Despite it's name, <PRE>URLENCODE</PRE> and <PRE>URLDECODE<PRE> don't have to be used ONLY on URL's - you can use them to easily pass string variables, or variables that have more than one word.
For example: I have a PHP script I use throughout my website that allows visitors to "rate" and send me a short "comment" about specific pages. The comment script automatically emails me any comments written. Instead of copying the code for the "comment" script onto each page, I call the script using an <PRE>INCLUDE( )</PRE> command.
Since it is important to me to know WHAT page on my website they are commenting on, I use a variable called <PRE>$TITLE</PRE> to tell me what page they sent the comment from!
However, the title of the page is often more than one word! For example, one page has a title of "Be Wary of Scholarship Scams"
So <PRE>$TITLE="Be Wary of Scholarship Scams"</PRE>
Problem: When the comment script sends me (via email) a comment from a visitor to that page, it just says <PRE>"TITLE= Be"</PRE> It's not sending me the ENTIRE title.
So on the included comment script I put the following code:
<PRE> $title=urlencode($title);</PRE>
In the actual script that sends me the comment, I put the following code:
<PRE> $title=urldecode($title);</PRE>
Problem solved :) Title now shows in the email as <PRE>"TITLE= Be Wary of Scholarship Scams"</PRE>
To see the comment script in action, go to http://www.freschinfo.com/tipsscam.phtml Just send me email if you would like a copy of it!
|