• Resolved bahadweikat

    (@bahadweikat)


    Hi,
    i have created form (“Name form”) using fluent form in wordpress and then i have used this form in a page (“Name Page”). The form has two text box (“first name”) and (“last name”). in the sql database (cpanel) i have also created table with same structure (“fname” as a varchar) and (“lname” as a varchar).

    now when i load the page (“Name Page”) the form loaded perfectly. but i want to store the values for both into the database once i click submit button.

    i tried to write php file , but it didnt work. i didnt know how to get the value of the text boxes from the form and pass them to the database. i also didnt know how to call the php file and where shall i put the file under which folder in the server.

    i have been looking for solution for more than a week and searching everywhere to find simple and detailed solution step by step how to do that without any luck? please help me.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Shahjahan Jewel

    (@techjewel)

    Hello @bahadweikat
    You have to use a submission action. Here is the in details docs: https://wpfluentforms.com/docs/submission-lifecycle/

    Basically you have to use fluentform_submission_inserted action hook.

    Please check this documentation:
    https://wpfluentforms.com/docs/fluentform_submission_inserted/

    add_action('fluentform_submission_inserted', 'your_custom_after_submission_function', 20, 3);
    
    function your_custom_after_submission_function($entryId, $formData, $form)
    {
      if($form->id != 5) {
          return;
       }
       // DO your stuffs here
    }

    Thanks

    Thread Starter bahadweikat

    (@bahadweikat)

    thank you @techjewel

    i looked on the documentation and i used the following code inside function.php file :

    add_action('fluentform_submission_inserted', 'your_custom_after_submission_function', 20, 3);
    
    function your_custom_after_submission_function($entryId, $formData, $form)
    {
      if($form->id != 5) {
          return;
       }
       
       global $wpdb;
    	
    	if (isset($_POST['submitbtn'])) {
    		global $wpdb;
    		$GText = $_POST['input_text'];
    		$wpdb->insert('sg_AdminPage',array('GymName'=>$Gtext));
            echo "record inserted";
    	}
       
    }

    i have created blank form in fluentforms contains only text input with name attribute is “input_text” and submit button (the default one), on submission the form is submitted without inserting the value of the text input inside the db. where is the mistake i did ?
    can you please help

    • This reply was modified 4 years, 2 months ago by bahadweikat.
    Thread Starter bahadweikat

    (@bahadweikat)

    it looks like the code ends when it goes inside the if statement ` if($form->id != 5) {
    return;
    }

    Thread Starter bahadweikat

    (@bahadweikat)

    i tried to put simple code after the word return like this :

     if($form->id != 5) {
         echo "test";     
         return; 
       }

    but on submission the form keep loading

    Plugin Author Shahjahan Jewel

    (@techjewel)

    It will keep loading because your are echo something which is invaliding the response json.
    Again, Please check the available hooks on form submission here:

    https://wpfluentforms.com/docs/submission-lifecycle/

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Saving custom wordpress form data into database’ is closed to new replies.