Title: run php code on submit
Last modified: August 30, 2016

---

# run php code on submit

 *  Resolved [francoiscarsys](https://wordpress.org/support/users/francoiscarsys/)
 * (@francoiscarsys)
 * [10 years, 6 months ago](https://wordpress.org/support/topic/run-php-code-on-submit/)
 * Hello,
 * Is it possible to run a php code when the user submits the form?
    I need the 
   information from the form to be added in a sql database.
 * I already have a plugin to insert php, but if i just put it in ‘additional settings’,
   it doesn’t work.
 * [insert_php]
    my code to add form to sql database [/insert_php]
 * [https://wordpress.org/plugins/contact-form-7/](https://wordpress.org/plugins/contact-form-7/)

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

 *  [davmerit](https://wordpress.org/support/users/davmerit/)
 * (@davmerit)
 * [10 years, 6 months ago](https://wordpress.org/support/topic/run-php-code-on-submit/#post-6757682)
 * > I need the information from the form to be added in a sql database
 * you can save your form information into a DB without writing a code 🙂
 * See [Contact Form DB](https://wordpress.org/plugins/contact-form-7-to-database-extension/)
 *  Thread Starter [francoiscarsys](https://wordpress.org/support/users/francoiscarsys/)
 * (@francoiscarsys)
 * [10 years, 5 months ago](https://wordpress.org/support/topic/run-php-code-on-submit/#post-6757710)
 * Thanks for the tip!
    But I already got it working by adding the following code
   to the function.php of the plugin:
 * add_action(‘wpcf7_mail_sent’, ‘your_wpcf7_mail_sent_function’);
 * function your_wpcf7_mail_sent_function($contact_form) {
    $title = $contact_form-
   >title; $submission = WPCF7_Submission::get_instance(); $posted_data = $submission-
   >get_posted_data();
 *  if (‘Form name’==$title) {
    MY PHP CODE!!! } }

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

The topic ‘run php code on submit’ is closed to new replies.

 * ![](https://ps.w.org/contact-form-7/assets/icon.svg?rev=2339255)
 * [Contact Form 7](https://wordpress.org/plugins/contact-form-7/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/contact-form-7/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/contact-form-7/)
 * [Active Topics](https://wordpress.org/support/plugin/contact-form-7/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/contact-form-7/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/contact-form-7/reviews/)

 * 2 replies
 * 2 participants
 * Last reply from: [francoiscarsys](https://wordpress.org/support/users/francoiscarsys/)
 * Last activity: [10 years, 5 months ago](https://wordpress.org/support/topic/run-php-code-on-submit/#post-6757710)
 * Status: resolved