urlencode and urldecode properly

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • salman1karim
    New Member
    • Dec 2006
    • 10

    urlencode and urldecode properly

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

    Code:
    window.open("http://www.abc.com/postcomment.php?nID="+id + "&song_name=" +songname + "&artist_name=" +artistname);
    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:
    Code:
    function getCurrentPageUrl()
            {
                    $pageURL = 'http';
                    if ($_SERVER["HTTPS"] == "on")
                    {
                            $pageURL .= "s";
                    }
    
                    $pageURL .= "://";
                    if ($_SERVER["SERVER_PORT"] != "80")
                    {
                            $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
                    }
                    else
                    {
                            $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
                    }
    
                    $url=urlencode($pageURL);
                    $result=urldecode($url);
                    return $result;
            }
    i call function when user sucessfully login:
    Code:
    passurl=getCurrentPageUrl();
    header("Location:$passurl");
    But i get incorrect url in internet explorer:


    and i get the correct url in firefox & google chrome as mentioned below:
    http://www.abc.com/postcomment.php ... song_name=ويتمي ز ايو&artist_name =مزيج المسا
  • johny10151981
    Top Contributor
    • Jan 2010
    • 1059

    #2
    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
    Code:
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
    In this case your page wont suffer with transferring data

    Comment

    • salman1karim
      New Member
      • Dec 2006
      • 10

      #3
      I already declare encoding in index.php and as well postcomment.php .
      Code:
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

      Comment

      Working...