How to GET URL from previous page and post it in the current page's URL

  • Profile Image
    reciproc8
    Asked on October 11, 2013 at 11:36 AM

    Hey guys

    I am trying to create a workaround with a problem I am expericning with some form work.  I need to get the URL from the 'referring' page to be added to the URL of the next page.  Can anyone tell me how to do this?

    Thanks!

  • Profile Image
    ardy0689
    Answered on October 11, 2013 at 12:29 PM

    Hello, this is possible to do via jQuery or Javascript with combined PHP/ASP on the receiving page.

    To do this please consider the following:

    1. You need to add a Hidden Box field anywhere in the form. This would be your entry point as this is hidden and can be set to any value automatically in the form or from an external script like Javascript.

     

    2. You need to configure the Form to "Send Post Data" where you can retrieve the POST array from PHP or ASP after submission.

     

    3. You also need to set a redirect from the Thank You Wizard to the page that will receive the HTTP post data.

     

     

     

    4. From the page where the form is located/embedded you need to devise a Javascript/jQuery to get the current page URL.

    5. When the script fetched the URL it can then be injected directly to the Form using the ID of the hidden box as the reference.

    6. When the form is filled up and submitted, it does 3 things:
         A.Sends submitted data to JotForm Server

         B.Sends the same submitted data via HTTP Post to the receiving custom page

         C. Sends email notification

    7. Now from the receiving page in this case http://mydomain.com/my-page-to-fetch-post-data.php

    you need to put a PHP or ASP script if it is an ASP/ASPX to fetch the submitted HTTP Post arrays.

    8. You can extract or locate the hidden box value from the POST array

    eg.
    PHP
    $URL=$_POST['hidden-text-field-name'];

    ASP
    Dim myURL
    myURL =Request.Form["hidden-text-field-name"]

     

    9. Do some header redirects and paste the extracted value to the URL of your choice to append it.

     

    This is the main idea and it should work in most cases. If you need further help please do not hesitate to ask. Thanks