Support » Plugin: Contact Form DB » Calculated Fields Form to DB

  • Hi All,

    I am trying to save the Calculated Fields From to the Database using the following code.

    <?php
    define( 'DATABASE_HOST',  'localhost' );
    define( 'DATABASE_USER',  'xxxx' );
    define( 'DATABASE_PASS',  'xxx' );
    define( 'DATABASE_NAME', 'xxx' );
    define( 'DATABASE_TABLE', 'hum_cf7dbplugin_submits' );
    
    if( DATABASE_HOST !== '' && DATABASE_USER !== '' && DATABASE_NAME !== '' && DATABASE_TABLE !== '' )
    {
    	try
    	{
    		$db_link = mysqli_connect( DATABASE_HOST, DATABASE_USER, DATABASE_PASS, DATABASE_NAME );
    		if( $db_link !== false )
    		{
    			$field1 = mysqli_escape_string( $db_link, $params[ 'fieldname1' ] );
    			$field2 = mysqli_escape_string( $db_link, $params[ 'fieldname8' ] );
    			$field3 = mysqli_escape_string( $db_link, $params[ 'fieldname104' ] );
    
    			mysqli_query( $db_link, "INSERT INTO <code>&quot;.DATABASE_TABLE.&quot;</code> (field1, field2, field3) VALUES (Schule, Kurs, Zusatzkurs);" );
    			mysqli_close($db_link);
    		}
    	}
    	catch( Exception $e )
    	{
    	}
    }
    ?>

    This code provided by the CFF Documentation. Is there something I am doing incorrectly or do I need to set some settings elsewhere?

    Thanks ion advance for any help.

    https://wordpress.org/plugins/contact-form-7-to-database-extension/

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Michael Simpson

    (@msimpson)

    I don’t see how this relates to the CFDB plugin.

    Thread Starter chrisonga

    (@chrisonga)

    Hello Michael,

    You are right it is slightly off-topic for the plugin but it is the plugin I am trying to communicate with so the client can export the form submissions as csv!

    I am assuming ‘hum_cf7dbplugin_submits’ is the right table to be writing to.

    I had no luck with the above code so I tried what was mentioned here (just added the shortcode):
    http://cfdbplugin.com/?page_id=508

    Which sent a result straight to the database but doesn’t seem to show any of the fields!

    Thanks again for any help!

    Plugin Author Michael Simpson

    (@msimpson)

    An easier way is to create an export link from the CFDB shortcode builder page that exports CSV, then use that to download.

    Also see: Accessing Form Data via PHP. It assumes your code is on the WordPress site. But if your client is on the same host, you could probably load the WP environment from wp_setting.php (or lookup what file needs to be loaded) then use the CFDB API.

    Thread Starter chrisonga

    (@chrisonga)

    Great Michael,

    I really appreciate your help here.
    Thanks so much.

    Regards,
    Chris

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Calculated Fields Form to DB’ is closed to new replies.