Home › Forums › Quform WordPress › Posting form variables to external php script.
- This topic has 9 replies, 3 voices, and was last updated 11 years, 4 months ago by sso7575.
- AuthorPosts
- July 26, 2013 at 10:01 pm #5467sso7575Participant
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,
BrianJuly 27, 2013 at 12:48 pm #5474AllySupport StaffYou don't have permission to view this content. Please log in or register and then verify your purchases to gain access.
July 27, 2013 at 3:32 pm #5488sso7575ParticipantThanks 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.
BrianJuly 29, 2013 at 8:59 pm #5521sso7575ParticipantAli,
I’ve spent hours trying to figure this out. Could you please give a short reply.
Thank you.
July 29, 2013 at 9:43 pm #5522gastonbesadaParticipantSorry, did you changed your Form ID -> find the form ID and your unique elements IDs -> find the element ID
July 29, 2013 at 11:58 pm #5526sso7575ParticipantHey 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!
BrianJuly 30, 2013 at 12:04 am #5527gastonbesadaParticipantHi, Your custom functions goes in /wp-content/themes/YOUR_THEME_DIR/functions.php always.
Thanks
July 30, 2013 at 1:37 am #5528sso7575ParticipantThanks 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.
July 30, 2013 at 2:07 am #5529gastonbesadaParticipantHi, 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_actionIn this case ‘iphorm_post_process’ is called by do_action(‘iphorm_post_process’, $form); when the form is successful submitted.
July 30, 2013 at 9:14 pm #5537sso7575ParticipantI think I finally got it!! Thanks for you help!!
- AuthorPosts
- You must be logged in to reply to this topic.