home|Jobs|Members|Downloads|Templates|Projects|links|Contact us |PHP News|
Welcome to PHP India, group, developers, Programmers, Freelancers, Outsourcing
PHP Resources
· Home
· Akaar
· Career/Jobs
· Disclaimer
· Downloads
· FAQ
· Feedback
· Free Web Services and Tools
· Members List
· PHP NEWS
· PHPClasses
· Private Messages
· Project Bidding
· Recommend Us
· Search
· Stories Archive
· Submit News
· Surveys
· Templates For You
· Top 10
· Topics
· Web Links
· World Visitors
· Your Account

Earn money from your website

Ready Templates


Website templates

Flash intro templates

Logo templates

Corporate Identity

Free Cliparts For You

Free Icons

Free Images

Free Fonts

Free Logo Types

Free Flash Buttons

Free 3D objects


Who is where
Membres:

Visiteurs:
01: 123.125.66.53 -> News
02: 178.154.161.29 -> Members_List
03: 38.107.191.95 -> FAQ
04: 38.107.191.96 -> FAQ
05: 38.107.191.97 -> Templates
06: 38.107.191.98 -> Topics
07: 38.107.191.99 -> Downloads
08: 66.249.68.111 -> Members_List
09: 67.195.114.240 -> bidding
10: 70.62.98.66 -> News
11: 72.30.161.219 -> More_News
12: 80.41.195.193 -> Downloads
Par Surf

Total Visits
We received
5351365
page views since May, 2003

New Download
· 1: NASDAQ 100
· 2: Outlook Express Spam Filter
· 3: Module for affiliate program of www.bravenet.com.
· 4: Phpnuke module to resell thousands of templates
· 5: Dataentry Screen Builder for MySQL
· 6: Akaar Documentation
· 7: Akaar with Standard Smarty Application
· 8: Akaar Demo Application
· 9: Script to send an Email From Data submitted on Form
· 10: File To display nice paging op page

Top Downloads
· 1: Script to send an Email From Data submitted on Form
[Downloads: 6912 x]
· 2: File To display nice paging op page
[Downloads: 5175 x]
· 3: Akaar Demo Application
[Downloads: 2465 x]
· 4: Module for affiliate program of www.bravenet.com.
[Downloads: 2158 x]
· 5: Phpnuke module to resell thousands of templates
[Downloads: 1963 x]
· 6: Akaar Documentation
[Downloads: 1953 x]
· 7: Dataentry Screen Builder for MySQL
[Downloads: 1885 x]
· 8: Akaar with Standard Smarty Application
[Downloads: 1879 x]
· 9: TemplateTamer
[Downloads: 1753 x]
· 10: NASDAQ 100
[Downloads: 1716 x]

FAQs
· PHP and Database (5)
· PHP AND HTML (1)
· PHP and other languages (4)
· PHP-General Information (6)
· PHP-Installation (12)
· Problems While working with PHP (10)
· Where can I obtain PHP? (6)

Visitors
Top Ten Visitor Countries for This Site

See all Countries

PHP India, group, developers, Programmers, Freelancers, Outsourcing FAQ (Frequently Asked Questions)



Category: Main -> PHP AND HTML

Question
·  What encoding/decoding do I need when I pass a value through a form/URL?

Answer
·  What encoding/decoding do I need when I pass a value through a form/URL?

There are several stages for which encoding is important. Assuming that you have a string $data, which contains the string you want to pass on in a non-encoded way, these are the relevant stages:
HTML interpretation. In order to specify a random string, you must include it in double quotes, and htmlspecialchars() the whole value.
URL: A URL consists of several parts. If you want your data to be interpreted as one item, you must encode it with urlencode().
Example 51-1. A hidden HTML form element


Note: It is wrong to urlencode() $data, because it's the browsers responsibility to urlencode() the data. All popular browsers do that correctly. Note that this will happen regardless of the method (i.e., GET or POST). You'll only notice this in case of GET request though, because POST requests are usually hidden.

";
?>

Example 51-2. Data to be edited by the user

<?php
    echo "<textarea name=mydata>
";
    echo htmlspecialchars($data)."
";
    echo "</textarea>";
?>

Note: The data is shown in the browser as intended, because the browser will interpret the HTML escaped symbols.

Upon submitting, either via GET or POST, the data will be urlencoded by the browser for transferring, and directly urldecoded by PHP. So in the end, you don't need to do any urlencoding/urldecoding yourself, everything is handled automagically.

Example 51-3. In an URL

<?php
    echo "<a href="" . htmlspecialchars("/nextpage.php?stage=23&data=" .
        urlencode($data)) . "">
";
?>

Note: In fact you are faking a HTML GET request, therefore it's necessary to manually urlencode() the data.


Note: In fact you are faking a HTML GET request, therefore it's necessary to manually urlencode() the data.
Note: You need to htmlspecialchars() the whole URL, because the URL occurs as value of an HTML-attribute. In this case, the browser will first un-htmlspecialchars() the value, and then pass the URL on. PHP will understand the URL correctly, because you urlencoded() the data.
You'll notice that the & in the URL is replaced by &. Although most browsers will recover if you forget this, this isn't always possible. So even if your URL is not dynamic, you need to htmlspecialchars() the URL.

[ Back to Top ]



Web site powered by PHP-Nuke

All logos and trademarks in this site are property of their respective owner. The comments are property of their posters, all the rest © 2002 by www.php-india.net
You can syndicate our news using the file backend.php or ultramode.txt
Connection timed out (110)
Web site engine's code is Copyright © 2002 by PHP-Nuke. All Rights Reserved. PHP-Nuke is Free Software released under the GNU/GPL license.
Page Generation: 0.083 Seconds