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
Generate Unique Number based on form name and an ID
Started 16 years ago by shay | 7 posts |
-
Hi,
I'm very new to MachForm and have a question about creating a unique number based on the form name and an ID.
The idea is I would like to be able to pass this unique name+ID to paypal when the form is submitted so I can identify which form relates to which payment.
I dont think this is available by default so am looking for some help from someone else who may have already done this.
Thanks in advance,
ShayPosted 16 years ago # -
Basically, we need to append the unique id into the redirect URL.
Since you require two parameter to be passed, we can use form id and record id.Take a look into includes/post-functions.php file, search around line 910 - 914:
if(empty($error_elements) && empty($process_result['custom_error'])){ $process_result['status'] = true; }else{ $process_result['status'] = false; }
Modify the code above to be like this:if(empty($error_elements) && empty($process_result['custom_error'])){ $process_result['status'] = true; $process_result['form_redirect'] = $form_redirect."?unique_id_1={$form_id}&unique_id_2={$record_insert_id}"; }else{ $process_result['status'] = false; }
That would append two parameters to your redirect URL. In this sample, we're adding unique_id_1 and unique_id_2, you can change this to whatever you need.MachForm Founder
Posted 16 years ago # -
Thanks for that, it works great. I assume this means that all forms I create will have these extra items if the form is redirected to another page?
Shay
Posted 16 years ago # -
Yes. If you would like to limit it to certain form only, you can use this code instead:
if(empty($error_elements) && empty($process_result['custom_error'])){ $process_result['status'] = true; if($form_id == 2){ $process_result['form_redirect'] = $form_redirect."?unique_id_1={$form_id}&unique_id_2={$record_insert_id}"; } }else{ $process_result['status'] = false; }
That would limit it to form with id = 2.MachForm Founder
Posted 16 years ago # -
Would it be possible to do this same thing, except pass some of the other field values along to the redirect page?
I would like to pass selected values along and then do some calculations with a javascript on my redirect page to have a total posted.
Posted 16 years ago # -
To pass some field values to your redirect page, your redirect page should be a PHP file.
Then follow the instruction here:
http://www.appnitro.com/forums/topic/how-to-limit-access-to-redirect-page-after-submission?replies=9#post-3176That would allow you to display your form values into your redirect page.
MachForm Founder
Posted 16 years ago # -
I figured it out... thanks so much!
Posted 16 years ago #
Reply
You must log in to post.