How to Display a Variable from JotForm on Thank You Page?

  • vistacollege
    Asked on October 13, 2015 at 5:41 AM

    Hi, I'm trying to display a variable from Jotform to a custom thank you page and need your help. Below are the details:

    Form: http://www.jotform.com//?formID=22267385809968

    SEND POST DATA is ENABLED

    Variable I'm trying to display is from a widget, to display a unique id. Which I followed the instruction from here: http://www.jotform.com/help/79-Add-Custom-Unique-IDs-to-your-Form-Submissions

    PHP on thank you page:


    $answers = $_POST;
    $var1 = array("leadid" => $answers[q18_input18][0]);

    echo $var1['leadid'];
    ?>

     

    Currently, I'm not able to get the variable value to display on the thank you page.

    When I tested the form, I also confirmed that the data is successfully inserted into jotform database.

    Please help. Thanks!

     

    - Dellon

  • mert JotForm UI Developer
    Replied on October 13, 2015 at 9:01 AM

    Hi Dellon,

    The following tutorial's Part 2 shows the steps to display variable on thank you page:

    http://www.jotform.com/help/213-Send-POST-Data-From-JotForm-Using-PHP-in-Custom-Thank-You-Page

     

    Also, the PHP code on redirect.php should be like the following:

     

    <?php 

    $answers = $_POST;

     $url1 = "http://www.titanic.com.au/submit.html"; // This is the URL address of the custom web page

     

    $var1 = "?input18=".urlencode($answers[input18]);

     

     $url2 = $url1.$var1;

     header("location:$url2");

    ?>

     

    Please, try the method from the tutorial and let us know about the final state of the issue.

    Thanks.

  • vistacollege
    Replied on October 13, 2015 at 2:45 PM
    Hi, i'm trying to display the variable value on the thank you page, not redirecting it to another page.
    Can you show me how to show the following text on the thank you page:
    "The value of input8 is: xxxxx"
    Thanks,
    Dellon
    ...
  • Ben
    Replied on October 13, 2015 at 5:01 PM

    You can check the following guide Dellon to see more about this: http://www.jotform.com/help/126-How-to-send-Submissions-to-Your-MySQL-Database-Using-PHP

    If you are looking for a code without reading the guide (for now) then this code would help you:

    $answers = $_POST;

    //We can do a check to make sure we capture data in both cases:
    if( isset($answers['q18_input18'] )

    {
      $var1 = array( 'leadid' => $answers['q18_input18'] );
    }
    elseif( isset($answers['input18'] )
    {
      $var1 = array('leadid' => $answers['input18']);
    }

    echo $var1['leadid'];
    ?>

    The reason why we check for both q18_input18 and input18 is because the later should be sent, but the original on your form is the first one (q18_input18) so it is possible to receive it as such.

    Do let us know if that works the way you wanted and if not, do let us know how we can assist you and we would be happy to do so :)

  • vistacollege
    Replied on October 14, 2015 at 2:45 PM
    Thank you so much for the code Ben. Unfortunately, it comes up blank when tested.
    Here’s the field from the source code: and we uses iframe on our site to display the jotform. We uses lightbox on www.vistacollege.edu homepage and iframe on any other pages. Tested both and no go. Any thoughts?
    Thanks,
    Dellon
    ...
  • Ben
    Replied on October 14, 2015 at 5:16 PM

    Hi Dellon.

    Yes, that is due to error on my side. I seem to have forgot the enclosing brackets for if statements.

    This code will however work properly:

    <?php
    $answers = $_POST;

    //We can do a check to make sure we capture data in both cases:
    if( isset($answers['q18_input18'] ) )
    {
      $var1 = array( 'leadid' => $answers['q18_input18'] );
    }
    elseif( isset($answers['input18'] ) )
    {
      $var1 = array('leadid' => $answers['input18']);
    }

    echo $var1['leadid'];
    ?>

    Please do let us know how it goes.

    If you want, you can also check out this clone of your form: http://form.jotformpro.com/form/52866785996987 to see how it working before making any changes (you would still need to make the changes on your own server, this would just show you the data that you get back.

  • vistacollege
    Replied on October 15, 2015 at 2:45 AM
    Perfect, thanks so much for your help!
    Dellon
    ...
  • mert JotForm UI Developer
    Replied on October 15, 2015 at 4:25 AM

    On behalf of my colleague Ben, you are welcome. I'm glad to see that the last solution works for you.

     

    If you need extra information, please let us know.

    Have a great day.