Posting form variables to external php script.

Home Forums Quform WordPress Posting form variables to external php script.

This topic is: resolved
Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #5467
    sso7575
    Participant

    I have been looking at this for hours now. All I am trying to do is submit a few variables with the form and pass them to my php script. No matter what I do I cannot get the variables to come across. I have the form set to redirect to my script on submit. If this was just using 2 files, and Notepad I would have it finished in about 5 seconds. I don’t understand why or what I am doing wrong regarding simply passing variables to another file/script via POST.

    Any help is appreciated.

    Thanks,
    Brian

    #5474
    Ally
    Support Staff

    You don't have permission to view this content. Please log in or register and then verify your purchases to gain access.

    #5488
    sso7575
    Participant

    Thanks Ally,

    I guess that would makes since then. I am going to lay out what I am doing exactly:

    I have been looking at that “sending a post request to another script” for a while now.

    1. I added the code to my functions.php and adjusted the values per the guide.
    2. I made a simple form with 2 drop down options.
    3. On submit the form redirects to another page that has the mytheme_post_to_another_script($form); being call via a Shortcode Exec PHP shorttag.
    ->The code is being called and works fine but the passed variables are always blank. I am assuming this because of what you said above.
    ->If that is correct I guess I am confused about how exactly you call the function. It seems that you would have to pass the values to that function waiting on the next page. If you didn’t the the form and the function would be the same page and the function would get called before you even submitted the form. Sorry for my lack of understanding here 🙂

    All I am trying to do is have my form send some variables to my script and then have the data come back across and create a table based off of the values that were sent.

    Please help me understand the best way to do this.

    Thanks for your help.
    Brian

    #5521
    sso7575
    Participant

    Ali,

    I’ve spent hours trying to figure this out. Could you please give a short reply.

    Thank you.

    #5522
    gastonbesada
    Participant

    Sorry, did you changed your Form ID -> find the form ID and your unique elements IDs -> find the element ID

    #5526
    sso7575
    Participant

    Hey there..yes I did. I think I am a little confused exactly where I put the add_action(‘iphorm_success_redirect_url_1’, ‘mytheme_modify_form_redirect’, 10, 2); This is going to call the function but is it supposed to be on the next page waiting to run or how exactly does that work?

    Thanks!
    Brian

    #5527
    gastonbesada
    Participant

    Hi, Your custom functions goes in /wp-content/themes/YOUR_THEME_DIR/functions.php always.

    Thanks

    #5528
    sso7575
    Participant

    Thanks I have it there. But when I am submitting the form how exactly do I call it? I have to submit the form to set the variables. But then do I have it redirect to another page and then call the function to execute my script? That is where I am getting confused.

    #5529
    gastonbesada
    Participant

    Hi, Is your script in functions.php ? If yes, you can use follow in functions.php:

    function your_custom_function($form)
    {
    $yourvar1 = $form->getValue('iphorm_1_3'); //you must change the unique element ID
    $yourvar2 = $form->getValue('iphorm_1_8'); //you must change the unique element ID
    $yourvar3 = $form->getValue('iphorm_1_12'); //you must change the unique element ID

    //do something with your values here
    //....

    //for debugging purpose
    echo '<script type="text/javascript">alert("values = '.$yourvar1.' '.$yourvar2.' '.$yourvar3'");</script>';
    }
    add_action('iphorm_post_process_1', 'your_custom_function'); //you must change the unique form ID

    Note: add_action is a WP hook used in plugin API
    http://codex.wordpress.org/Function_Reference/add_action

    In this case ‘iphorm_post_process’ is called by do_action(‘iphorm_post_process’, $form); when the form is successful submitted.

    #5537
    sso7575
    Participant

    I think I finally got it!! Thanks for you help!!

Viewing 10 posts - 1 through 10 (of 10 total)
  • You must be logged in to reply to this topic.
Be inspired. © 2024 ThemeCatcher Ltd. 20-22 Wenlock Road, London, England, N1 7GU | Company No. 08120384 | Built with React | Privacy Policy