Total members 11653 |It is currently Thu Jul 27, 2017 5:43 am Login / Join Codemiles

Java

C/C++

PHP

C#

HTML

CSS

ASP

Javascript

JQuery

AJAX

XSD

Python

Matlab

R Scripts

Weka





There are some cases when you are passing parameters via URL you need to encode the parameters values. Many languages have a built in function for URL encoding:
For Python:
Code:
import urllib

print "Get URL : http://codemiles.com/test.py?password=%s" % (urllib.quote_plus(password))

For JavaScript:
Code:
var urlWithParam = "http://codemiles.com/index.php?password=" + encodeURIComponent(password);

For Perl:
Code:
use URI::Escape;

$myURL = sprintf('http://codemiles.com/myPage.php?password=%s',uri_escape($password));

sub encodeParam {
    my $s = shift;
    $s =~ s/ /+/g;
    $s =~ s/([^A-Za-z0-9\+-])/sprintf("%%%02X", ord($1))/seg;
    return $s;
}

$myURL = sprintf('http://codemiles.com/test.php?password=%s', encodeParam ($password)

For ASP.NET:
Code:
String nextPage;
nextPage = "http://codemiles.com/index.php?password=" + Server.UrlEncode(password);

Response.Write("<a href=" + nextPage + ">Submit Page</a>");

For PHP:
Code:
<?php
print '<a href="://codemiles.com/index.php?password=', urlencode($passowrd), '">Next Page</a>';
?>





Author:
Mastermind
User avatar Posts: 2707
Have thanks: 74 time
Post new topic Reply to topic  [ 1 post ] 

  Related Posts  to : Encoding parameters in URL
 session Encoding Data in php     -  
 URL Characters and URL Encoding Values     -  
 usage of the meta tag for content encoding     -  
 Reference Parameters     -  
 Method Parameters,,,is it by value or reference???     -  
 get url, title and url sent parameters with JQuery     -  
 Function with default parameters     -  
 Send parameters using HTTP GET     -  
 Post parameters using JQuery     -  
 Implicit and Explicit Parameters,,,What's the differences?     -  



cron






Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team