Advanced Search

Results 1 to 8 of 8

Thread: Reading the URL and parsing it.

  1. #1
    Join Date
    Mar 2006
    Location
    Belgium
    Posts
    81
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Question Reading the URL and parsing it.

    Another question, related to my previous post...

    When sending a variable with a form I use
    Code:
    <form action="index.php" method="get">
    and with the variables I am using it would lead me to a page such as http:/ /www.test.com/index.php?lang=english

    now I would like to read the that URL with some script but without the variable (?lang=english) and parse that into the action attribute of that form.

    How can I do that?
    Last edited by Rohan72; 02-22-2010 at 12:21 AM.

  2. #2
    Join Date
    Jan 2008
    Posts
    4,158
    Thanks
    28
    Thanked 623 Times in 619 Posts
    Blog Entries
    1

    Default

    Use:
    Code:
    method="post"
    Then when you read the variable you normally would do $_GET['lang'] but now you would do $_POST['lang']
    Jeremy | jfein.net

  3. #3
    Join Date
    Mar 2006
    Location
    Belgium
    Posts
    81
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default

    Nile, I think you misunderstood my question.
    I would like to read the URL from the page I am currently on and then parse that into the form.
    Something like this:

    URL = http:/ /www.test.com/index.php?lang=english
    Code:
    <?php
    script to read the URL - ?lang=english
    ?>
    
    <form action="the url just retrieved by the phpscript" method="get"

  4. #4
    Join Date
    Jan 2008
    Posts
    4,158
    Thanks
    28
    Thanked 623 Times in 619 Posts
    Blog Entries
    1

    Default

    Then use $_GET['lang']... Or am I still misunderstanding you?
    Jeremy | jfein.net

  5. #5
    Join Date
    Mar 2006
    Location
    Belgium
    Posts
    81
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default

    I am afraid you do...

    I'll take this page as an example.

    If I had the form on this page, I would like a phpscript to read the URL and delete the "?t=52583" part from it so that the form tag would something like
    Code:
    <form action="<?php echo $UrlFromAbove ?>" method="get">
    so when viewing the source code in IE, you would see it like
    Code:
    <form action="http://www.dynamicdrive.com/forums/showthread.php" method="get">
    This is because the form is not on the page itself, but in a footer, that I include in every page.

  6. #6
    Join Date
    Jan 2008
    Posts
    4,158
    Thanks
    28
    Thanked 623 Times in 619 Posts
    Blog Entries
    1

    Default

    Use _SERVER["PHP_SELF"]
    Jeremy | jfein.net

  7. The Following User Says Thank You to Nile For This Useful Post:

    Rohan72 (02-22-2010)

  8. #7
    Join Date
    Mar 2006
    Location
    Belgium
    Posts
    81
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default

    Thanks a lot!

    problem solved

  9. #8
    Join Date
    Jan 2008
    Posts
    4,158
    Thanks
    28
    Thanked 623 Times in 619 Posts
    Blog Entries
    1

    Default

    Glad to help.
    Jeremy | jfein.net

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •