Viewing 15 replies - 1 through 15 (of 18 total)
  • Thread Starter Versari

    (@versari)

    I already tried with this:
    http://cfdbplugin.com/?page_id=239

    but I’d like that plugin automatically saves info like that…

    Plugin Author Michael Simpson

    (@msimpson)

    You can create a View in the DB like the link you cited says so that it looks like a table.

    Alternately, you could hook in some code to write the form data to your own table. Refer to Changing Data Before it is Saved but instead of changing it, you would put in the code to save to your table.

    And if you want to know why things are set up this way, read this.

    Thread Starter Versari

    (@versari)

    I read all the links you give me before asking the question and I tried to make some changes but without success..

    Can you gently give me a simple template set for example name, email and date as colums and put all the data in a single row?

    Thanks in advance Michael.

    [ No bumping please. ]

    Plugin Author Michael Simpson

    (@msimpson)

    I was hoping for more info. What are the field types? Is this a multipart form? How does it integrate with PayPal? Are they any special settings?

    Thread Starter Versari

    (@versari)

    It doesn’t integrate Paypal.
    There are two different types of Contact Form.

    The first type has these fields:

    [text* nome watermark "Nome e Cognome"]
    [text* indirizzo watermark "Indirizzo"]
    [text* cap watermark "CAP"]
    [text* provincia watermark "Provincia"]
    [email* email watermark "E-mail"]
    [tel telefono watermark "Telefono"]
    [textarea messaggio watermark "Messaggio"]
    Accetta i Termini di servizio [acceptance privacy]
    [submit "Invia"]</p>

    and the second one has these fields:

    [text* nome watermark "Nome e Cognome"]
    [email* email watermark "E-mail"]
    [tel telefono watermark "Telefono"]
    Accetta i Termini di servizio [acceptance privacy]
    [submit "Invia"]</p>

    Plugin Author Michael Simpson

    (@msimpson)

    Sorry, I replied to the wrong thread here (hence the PayPal reference).

    I’m not clear on if you are trying to make a View or to save the form submissions into your own table.

    Thread Starter Versari

    (@versari)

    I already created a View, but I’d like to save form submissions in a different way as it saves right now.

    I’d like to create one row per contact form with field names as columns

    Thread Starter Versari

    (@versari)

    The View I created:

    SELECTsubmit_time AS ‘Submitted’,
    max(if(field_name=’nome’, field_value, null )) AS ‘nome’,
    max(if(field_name=’indirizzo’, field_value, null )) AS ‘indirizzo’,
    max(if(field_name=’cap’, field_value, null )) AS ‘cap’,
    max(if(field_name=’provincia’, field_value, null )) AS ‘provincia’,
    max(if(field_name=’email’, field_value, null )) AS ’email’,
    max(if(field_name=’telefono’, field_value, null )) AS ‘telefono’,
    max(if(field_name=’messaggio’, field_value, null )) AS ‘messaggio’,
    max(if(field_name=’privacy’, field_value, null )) AS ‘privacy’,
    max(if(field_name=’tipo’, field_value, null )) AS ‘tipo’,
    max(if(field_name=’Submitted Login’, field_value, null )) AS ‘Submitted Login’,
    max(if(field_name=’Submitted From’, field_value, null )) AS ‘Submitted From’,
    GROUP_CONCAT(if(file is null or length(file) = 0, null, field_name)) AS ‘fields_with_file’
    FROM wp_cf7dbplugin_submits
    WHERE form_name = ‘Contact1’
    GROUP BY submit_time
    ORDER BY submit_time DESC
    LIMIT 0,100

    I’d like to save forms on the db like this view.

    Plugin Author Michael Simpson

    (@msimpson)

    Create a table in your database with the fields you want.

    Referencing Changing Form Data Before it is Saved, in your “myfilter” function (or whatever you name it), you need to insert the information into your table.

    declare:
    global $wpdb;
    then you basically want to call $wpdb->insert( $table, $data, $format ); where you can pass in $formData->posted_data for $data. Those are all string values, so if your DB table has other types like int, then you will have to convert them and use the $format variable. (refer to $wpdb documentation).

    Thread Starter Versari

    (@versari)

    Can you gently post here a simple template/example so I can start with it?

    Thanks in advance

    Plugin Author Michael Simpson

    (@msimpson)

    I don’t have any.

    Thread Starter Versari

    (@versari)

    I can’t fully understand your previous post, can you gently tell me full steps?

    Sorry for the inconvenience Michael.

    [ No bumping please. ]

    Plugin Author Michael Simpson

    (@msimpson)

    I’ve outlined what you need to do. But it’s up to you to write your own code. You may find that you need help from someone with more knowledge of PHP & WP to create the code.

    Thread Starter Versari

    (@versari)

    Michael, is it possible to extract data from a view? Can be considered a table?

    Plugin Author Michael Simpson

    (@msimpson)

    Yes, query it as if it were a table. But you cannot update data in it

Viewing 15 replies - 1 through 15 (of 18 total)

The topic ‘Form to Database in one row’ is closed to new replies.