By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,369 Members | 966 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,369 IT Pros & Developers. It's quick & easy.

urlencode and urldecode properly

P: 10
I pass three variables through javacripting and these variable fetch from flash.

Expand|Select|Wrap|Line Numbers
  1. window.open("http://www.abc.com/postcomment.php?nID="+id + "&song_name=" +songname + "&artist_name=" +artistname);
  2.  
Inside variable have Arabic character (UTF-8) and Url should like this:
http://www.abc.com/postcomment.php ... song_name=ويتميز ايو&artist_name=مزيج المسا

Before opening the page checked the user log in information. If not then went to login page after user successful log in it will come to last page from where user are giving comments. But the problem is that when I read url from urlencode() and after decode in php. It's working in mozila firefox but in internet explorer is not working. Php code is mentioned below:
Expand|Select|Wrap|Line Numbers
  1. function getCurrentPageUrl()
  2.         {
  3.                 $pageURL = 'http';
  4.                 if ($_SERVER["HTTPS"] == "on")
  5.                 {
  6.                         $pageURL .= "s";
  7.                 }
  8.  
  9.                 $pageURL .= "://";
  10.                 if ($_SERVER["SERVER_PORT"] != "80")
  11.                 {
  12.                         $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
  13.                 }
  14.                 else
  15.                 {
  16.                         $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
  17.                 }
  18.  
  19.                 $url=urlencode($pageURL);
  20.                 $result=urldecode($url);
  21.                 return $result;
  22.         }
  23.  
i call function when user sucessfully login:
Expand|Select|Wrap|Line Numbers
  1. passurl=getCurrentPageUrl();
  2. header("Location:$passurl");
But i get incorrect url in internet explorer:
http://www.abc.com/postcomment.php?n...?????%20??????

and i get the correct url in firefox & google chrome as mentioned below:
http://www.abc.com/postcomment.php ... song_name=ويتميز ايو&artist_name=مزيج المسا
Oct 3 '11 #1
Share this Question
Share on Google+
2 Replies


100+
P: 1,059
your page will have to clearly know what kind of encoding you are using. that is, you must have to tell your brwoser clearly. example
Expand|Select|Wrap|Line Numbers
  1. <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
In this case your page wont suffer with transferring data
Oct 4 '11 #2

P: 10
I already declare encoding in index.php and as well postcomment.php.
Expand|Select|Wrap|Line Numbers
  1. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
Oct 4 '11 #3

Post your reply

Sign in to post your reply or Sign up for a free account.