Total members 11895 |It is currently Thu Dec 05, 2024 7:06 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>';
?>




_________________
M. S. Rakha, Ph.D.
Queen's University
Canada


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

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









Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com