Results 1 to 14 of 14

Thread: Grabbing info before form processed

  1. #1
    Join Date
    Aug 2007

    Grabbing info before form processed

    I have an interesting predicament. I have a form that connects to an external website for credit card payments. Thing is, I want to save all the information before it gets processed, otherwise I never get to see it. The form looks something like this:

    PHP Code:
    <form action="https://www.myvirtualmerchant.com/VirtualMerchant/process.do" method="post">
    input type="hidden" name="ssl_pin" value="1234" />
    input type="hidden" name="ssl_transaction_type" value="ccsale" />
    input type="hidden" name="ssl_show_form" value="false" />
    input type="text" maxlength="30" size="35" name="ssl_card_number"/>
    input type="text" maxlength="7" size="7" name="ssl_cvv2cvc2" /> 
    And so on and so forth...

    Is it possible to have the form redirect to the current page then save all the variables, add them to my dbases, then somehow send them all as POST variables like they're supposed to, to the http://www.myvirtualmerchant.com/Vir...ant/process.do website?

  2. #2
    Join Date
    Oct 2006
    There a a couple of ways I would think about doing it. The simplest way doing something like saving the variables and loading the page with a new form of hidden variables to post to the merchant and then putting a form submit command in the body onLoad trigger.

    Another good but more complicated way is to use ajax to first load a simple page into a div which saves the variables and then submits the form. I could provide more detail but it could be somewhat complicated if you haven't used ajax before.

  3. #3
    Join Date
    Aug 2007
    I've used ajax before, you mind providing more detail?

  4. #4
    Join Date
    Oct 2006
    I tend to use the scripts from script.aculo.us for my ajax but just prototype should do for this.

    You could use the Ajax.Updater function to load a page into an invisible div that saves the data and then uses javascript to submit the form.

    You could have a normal linked image onClick or use a onSubmit call in the form but the javascript on the submit should look something like this:
    new Ajax.Updater('you_div', 'record_data.php', {parameters:Form.serialize(document.data_form), evalScripts:true});
    In this case record_data.php is loaded into the div 'your_div' which can save the data for you. The 'parameters' option passes the form values as post variables and the 'evalScripts' option means that any javascript in record_data.php is also run when it is loaded in. You might be able just do that in the onSubmit call in the form and then it submits normally without anything else needing doing but I'm not sure. That will probably require the 'asynchronous: false, ' option so that the page waits for the record_data page to be loaded before submitting the form.

    Hope this helps

  5. #5
    Join Date
    Aug 2007
    Where would I put the asynchronous: false part? Or could I just run the actual submital of the form off a window.onload on the record_data?

  6. #6
    Join Date
    Oct 2006
    I'm thinking that you could just put the following in your form:

    <form onSubmit="new Ajax.Updater('your_div', 'record_data.php', {parameters:Form.serialize(document.data_form), asynchronous: false});">
    I would hope that the page would then wait for record_data.php to be loaded before submitting the form.

    If it didn't then I would put a 'false;' return after the ajax call so that the form didn't submit and then run the ajax call with the 'evalScripts:true' option and then put
    in the record_data.php page to submit the form when it is done loading.

  7. #7
    Join Date
    Aug 2007
    What do you mean by a false return after the ajax call? I think I know what youre getting at, and everything seems to be working ok, but I would just like to make sure.

    And also, thanks for your help, this looks to be a very clean, quick method to do this.

  8. #8
    Join Date
    Oct 2006
    I just meant that maybe you would need to put
    return false;
    after the ajax call to stop the form submitting if the ajax page didn't have time to update the data. If though it's all being saved properly then you don't need to worry.

    Glad to hear it's working for you

  9. #9
    Join Date
    Aug 2004
    That wouldn't work if the user had javascript turned off though.

    Why not have two pages, the first being the form and the inputs that is submitted to your site. On the next page it will echo the data out and say something like "Please can you check all your details are correct" then have a hidden form will all the data and a submit button to the external site..

  10. #10
    Join Date
    Oct 2006
    Well if you were worried about people not having javascript running then you could have the javascript degrade gracefully so that the javascript will send the form to the right place and if not it will go to the non-javascript page you speak of.

  11. #11
    Join Date
    Aug 2004
    Yeah that would work - it's just that things that involve money should be taken seriously and if its imperitive that the data is needed then relying on javascript is too much of a risk
    Last edited by artemis; 05-04-2008 at 11:00 AM.

  12. #12
    Join Date
    Oct 2006
    Indeed, it is worth considering.

  13. #13
    Join Date
    Aug 2007
    Why would relying on javascript be too much of a risk?

  14. #14
    Join Date
    Aug 2004
    Well I was just saying that if you *really* need the form data if its to do with paying you etc then there is always a chance that the user will not have javascript turned on. if this is the case then the ajax method wont work and you have the data for that 'transaction'. it is only a small thing as the majority of people have it turned on but i find it best that when dealing with money transactions to try to account for all eventualities - just my two cents though, you can of course do it however you like

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



X vBulletin 4.2.2 Debug Information

  • Page Generation 0.12505 seconds
  • Memory Usage 2,996KB
  • Queries Executed 13 (?)
More Information
Template Usage (34):
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_global_above_footer
  • (1)ad_global_below_navbar
  • (1)ad_global_header1
  • (1)ad_global_header2
  • (1)ad_navbar_below
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)ad_thread_first_post_content
  • (1)ad_thread_last_post_content
  • (4)bbcode_code
  • (1)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)headinclude_bottom
  • (14)memberaction_dropdown
  • (1)navbar
  • (4)navbar_link
  • (1)navbar_moderation
  • (1)navbar_noticebit
  • (1)navbar_tabs
  • (2)option
  • (14)postbit
  • (14)postbit_onlinestatus
  • (14)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available (6):
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files (26):
  • ./showthread.php
  • ./global.php
  • ./includes/class_bootstrap.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/functions_navigation.php
  • ./includes/class_friendly_url.php
  • ./includes/class_hook.php
  • ./includes/class_bootstrap_framework.php
  • ./vb/vb.php
  • ./vb/phrase.php
  • ./includes/functions_facebook.php
  • ./includes/functions_calendar.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_notice.php
  • ./packages/vbattach/attach.php
  • ./vb/types.php
  • ./vb/cache.php
  • ./vb/cache/db.php
  • ./vb/cache/observer/db.php
  • ./vb/cache/observer.php 

Hooks Called (70):
  • init_startup
  • friendlyurl_resolve_class
  • init_startup_session_setup_start
  • database_pre_fetch_array
  • database_post_fetch_array
  • init_startup_session_setup_complete
  • global_bootstrap_init_start
  • global_bootstrap_init_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • load_show_variables
  • load_forum_show_variables
  • global_state_check
  • global_bootstrap_complete
  • global_start
  • style_fetch
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • strip_bbcode
  • friendlyurl_clean_fragment
  • friendlyurl_geturl
  • forumjump
  • cache_templates
  • cache_templates_process
  • template_register_var
  • template_render_output
  • fetch_template_start
  • fetch_template_complete
  • parse_templates
  • fetch_musername
  • notices_check_start
  • notices_noticebit
  • process_templates_complete
  • friendlyurl_redirect_canonical
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • memberaction_dropdown
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • build_navigation_data
  • build_navigation_array
  • check_navigation_permission
  • process_navigation_links_start
  • process_navigation_links_complete
  • set_navigation_menu_element
  • build_navigation_menudata
  • build_navigation_listdata
  • build_navigation_list
  • set_navigation_tab_main
  • set_navigation_tab_fallback
  • navigation_tab_complete
  • fb_like_button
  • showthread_complete
  • page_templates