get the full address bar URL

Discussion in 'PHP' started by Kyriakos, May 16, 2008.

  1. #1
    hi everyone,

    i want to get the full url of address bar (including queries) inside a hidden field. this is an asp example:
    <input type="hidden" name="my_url" value="<%
    Dim strDomain, strPath, strQueryString, strURL
    strDomain = Request.ServerVariables("HTTP_HOST")
    strPath = Request.ServerVariables("URL")
    strQueryString = Request.ServerVariables("QUERY_STRING")
    strURL = "http://" & strDomain & strPath & "?" & strQueryString
    response.write strURL
    %>"/>
    HTML:
    can anybody convert this to php?

    thanks in advance.
     
    Kyriakos, May 16, 2008 IP
  2. Dondon2d

    Dondon2d Peon

    Messages:
    3,193
    Likes Received:
    146
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Try this:

    <input type="hidden" name="my_url" value="
    <? 
    $strDomain=$_SERVER["HTTP_HOST"];
    $strPath=$_SERVER["URL"];
    $strQueryString=$_SERVER["QUERY_STRING"];
    $strURL="http://" . $strDomain . $strPath. "?" .$strQueryString;
    echo $strURL;
    ?>
    "/> 
    PHP:
    Don't really know if it works :D Just put that up in random. Don't have time to try it yet.
     
    Dondon2d, May 16, 2008 IP
  3. Kyriakos

    Kyriakos Active Member

    Messages:
    155
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    51
    #3
    thanks dude. it's working
     
    Kyriakos, May 16, 2008 IP
  4. Dondon2d

    Dondon2d Peon

    Messages:
    3,193
    Likes Received:
    146
    Best Answers:
    0
    Trophy Points:
    0
    #4
    No problem buddy. Glad to be of help :D
     
    Dondon2d, May 16, 2008 IP