This forum is no longer open and is for reading/searching only.

Please use our new MachForm Community Forum instead.

MachForm Community Forums » MachForm 2

Repopulate form field with session variable


  1. msfbiz
    Member

    I have created an order form that people fill out before being directed to a payment site like PayPal.

    On the payment site they have the choice to 'Cancel & Return to Merchant' before making the payment and that directs them back to the order form.

    However all form fields are empty and if the person wants to place the order s/he needs to fill out the form again.

    Is there a way to repopulate the form with session variables that would have been created after the form has been submitted once, so that people don't have to fill out the form again?

    Thanks!
    Mike

    Posted 13 years ago #
  2. msfbiz
    Member

    Is it possible to get support (or at least an answer) on this issue please?

    Thanks!
    Mike

    Posted 13 years ago #
  3. yuniar

    Sorry for the delay on this.

    It is possible to do so, however the second submission won't simply update the previous submission, instead it will be submitted as a new entry.

    First, you will need to enable "form review" for your form.

    Then edit "confirm.php" and "confirm_embed.php" file.
    Around line 32 you'll find this:

    unset($_SESSION['review_id']);

    delete that line and save your files.

    Then, edit your "includes/post-functions.php" file, around line 2322 (pretty close at the bottom of that file) you'll find this:

    do_query("DELETE FROM ap_form_{$form_id}_review where id='{$record_id}' or session_id='{$session_id}'");

    delete that line as well.

    That would allow your users to go back to the form and the session variables will be preserved.


    MachForm Founder

    Posted 13 years ago #
  4. msfbiz
    Member

    Hi Yuniar,

    Your solution works partially: all the session variables are preserved if I click the 'Back' button from the review page.

    However, if I click the 'Next' button to go to the payment page and then click the 'Cancel' button on the payment page, this redirects me to the page of the form to fill out, but all the variables are lost.

    Also, I would like to make it work without the 'review form' enabled.

    I guess I would like to always (or at least for some form ids) have session variables created and never unset/lose them, so the form is always populated if I go back to it.

    How can I change the code to achieve that?

    Thanks!
    Mike

    Posted 13 years ago #
  5. yuniar

    Hi Mike,

    I'm afraid it won't be easy to make it work without "review form" enabled. As it would require pretty much custom code.

    The above code should be working just fine, even though you have go through to the payment page and go back.

    If it's not working, then there might be something missing.

    Please send me your files:
    - confirm.php
    - confirm_embed.php
    - includes/post-functions.php

    Also, please let me know the URL to your form, so I can test it.

    You can mail it to: customer.service [at] appnitro.com

    I'll help you there.


    MachForm Founder

    Posted 13 years ago #

RSS feed for this topic

Reply