note 522 deleted from function.urlencode by didou
| From: | didou@php.net | Date: | Mon, 06 Oct 2003 15:56:12 +0000 |
| Subject: | note 522 deleted from function.urlencode by didou | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-57899@lists.php.net to get a copy of this message | ||
Note Submitter: reisa@plinet.com
----
Newbie Notes:
Despite it's name, URLENCODE and URLDECODE 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 INCLUDE( ) command.
Since it is important to me to know WHAT page on my website they are commenting on, I use a variable
called $TITLE 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 $TITLE="Be Wary of Scholarship Scams"
Problem: When the comment script sends me (via email) a comment from a visitor to that page, it
just says "TITLE= Be" It's not sending me the ENTIRE title.
So on the included comment script I put the following code:
$title=urlencode($title);
In the actual script that sends me the comment, I put the following code:
$title=urldecode($title);
Problem solved :) Title now shows in the email as "TITLE= Be Wary of Scholarship Scams"
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!