Title: Send values via POST to php
Last modified: September 1, 2016

---

# Send values via POST to php

 *  Resolved [hornetsecurity](https://wordpress.org/support/users/hornetsecurity/)
 * (@hornetsecurity)
 * [9 years, 9 months ago](https://wordpress.org/support/topic/send-values-via-post-to-php/)
 * Hello,
 * I just can’t figure out how to send the values entered in a form to be send per
   POST to a php file.
 * Is the following the right way?:
    Lets say I have 2 single line text fields (
   fieldname1 and fieldname2). I add a button and fill in its settings at the OnClick
   event send(); for the function send. Then I add a HTML content field where I 
   place the function. How should the code for the function send(); look like? Could
   you help me or give an example code for the example case above?
 * Best Regards Tobi
 * [https://wordpress.org/plugins/calculated-fields-form/](https://wordpress.org/plugins/calculated-fields-form/)

Viewing 4 replies - 1 through 4 (of 4 total)

 *  Plugin Author [codepeople](https://wordpress.org/support/users/codepeople/)
 * (@codepeople)
 * [9 years, 9 months ago](https://wordpress.org/support/topic/send-values-via-post-to-php/#post-7637384)
 * Hi,
 * What version of the plugin are you using? The Professional version of the plugin
   includes the submission feature, and manages the collected data by the form. 
   It can send notification emails, and store the data in the plugin’s database.
 * However, if you want submit the form to your own script and manage the form by
   yourself, you can use jQuery to assign the “action” attribute to the form (with
   the absolute URL to your script), and then call the “submit” method of the form
   object.
 * If you need additional help with the code, I can offer you a custom coding service
   through my private support page:
 * [http://cff.dwbooster.com/contact-us](http://cff.dwbooster.com/contact-us)
 * Best regards.
 *  Thread Starter [hornetsecurity](https://wordpress.org/support/users/hornetsecurity/)
 * (@hornetsecurity)
 * [9 years, 9 months ago](https://wordpress.org/support/topic/send-values-via-post-to-php/#post-7637542)
 * Hi,
 * I use the free version. I think it’s enough for our issues.
    How can I implement
   a jQuery script correctly?
 * I have the following little script which I added to a html content field:
 * <script>
    $(document).ready(function(){ $(‘#button’).click(function() { var val1
   = $(‘#tfieldname1).val(); var val2 = $(‘#fieldname2’).val(); $.ajax({ type: ‘
   POST’, url: ‘ThePHPfile.php’, data: { fieldname1: val1, fieldname2: val2 }; });});});
   </script>
 * The script doesn’t work. If I paste this code to the formular the form is not
   loading correct. And – What do I have to define to the button?
 *  Plugin Author [codepeople](https://wordpress.org/support/users/codepeople/)
 * (@codepeople)
 * [9 years, 9 months ago](https://wordpress.org/support/topic/send-values-via-post-to-php/#post-7637556)
 * Hi,
 * Your code has multiple javascript errors, I will try to give you some tips, but
   if you need additional help, you should hire a custom coding service ([http://cff.dwbooster.com/customization](http://cff.dwbooster.com/customization))
 * First, don’t use the the $ symbol, use the object: jQuery.
 * Second, if you have inserted only one form in the page, and you want get the 
   values of fields using their IDs as selector, the correct selectors are: fieldname#_#,
   where the # at the end of selector represents a consecutive integer based in 
   the amount of forms in the page, for example:
 *     ```
       var val1 = jQuery('#tfieldname1_1).val();
       var val2 = jQuery('#fieldname2_1').val();
       ```
   
 * Third, there is not a #button field, the buttons have assigned a fieldname# too,
   so, you should refer to this field as fieldname#_#, similar to the other fields
   in the form.
 * Fourth, you should use an absolute url to the php script: [http://&#8230](http://&#8230);..
 * Fifth, use the onload event of the window object, instead the document ready 
   event:
 * `jQuery(document).on('load', function(){});`
 * Best regards.
 *  Thread Starter [hornetsecurity](https://wordpress.org/support/users/hornetsecurity/)
 * (@hornetsecurity)
 * [9 years, 9 months ago](https://wordpress.org/support/topic/send-values-via-post-to-php/#post-7637561)
 * Thank you very much. I will check if I get it to run. If not I will contact your
   custom config service.
 * Best Regards,
 * Tobi

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Send values via POST to php’ is closed to new replies.

 * ![](https://ps.w.org/calculated-fields-form/assets/icon-256x256.jpg?rev=1734377)
 * [Calculated Fields Form](https://wordpress.org/plugins/calculated-fields-form/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/calculated-fields-form/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/calculated-fields-form/)
 * [Active Topics](https://wordpress.org/support/plugin/calculated-fields-form/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/calculated-fields-form/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/calculated-fields-form/reviews/)

## Tags

 * [php](https://wordpress.org/support/topic-tag/php/)
 * [post](https://wordpress.org/support/topic-tag/post/)
 * [values](https://wordpress.org/support/topic-tag/values/)

 * 4 replies
 * 2 participants
 * Last reply from: [hornetsecurity](https://wordpress.org/support/users/hornetsecurity/)
 * Last activity: [9 years, 9 months ago](https://wordpress.org/support/topic/send-values-via-post-to-php/#post-7637561)
 * Status: resolved