• Hello again,

    my problem is that when i’m loading a page with a value changed in the database, the new value doesn’t show up (instead the default-old value shows up). I’ll add an example in order to understand it better.

    User fills a form that has a hidden field default at zero.
    There is a page that loads the form with a specific format and a button.
    When a user clicks the button, the value in the hidden field is increased with one.
    When the page gets refreshed the text that shows the value remains zero.

    The entry in the contact forms panel doesn’t change.

    Any ideas?

    Thanks a lot

    https://www.ads-software.com/plugins/contact-form-7-to-database-extension/

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

    (@msimpson)

    How do you make the form get the value from the database to populate the hidden field?

    Thread Starter gladi

    (@gladi)

    I make use of the “create your own shortcode” using php.

    require_once(ABSPATH . 'wp-content/plugins/contact-form-7-to-database-extension/CFDBFormIterator.php');
    $exp = new CFDBFormIterator();
    $exp->export($atts['form'], $atts);
    while ($row = $exp->nextRow()) {
    
    //simple if condition
    echo $row['myvariable here']
    }

    Should i use $wpdb->get_var(/*query goes here*/)?

    Thanks.

    Plugin Author Michael Simpson

    (@msimpson)

    No.

    That code will output every the value for every form submission.

    If you want to display a form where a hidden field has a number that is +1 each time it is displayed, then perhaps it would be better to set up a table in MySQL with an AUTO_INCREMENT field.

    Thread Starter gladi

    (@gladi)

    It doesn’t work that way. Anyway, i did it with $wpdb->get_var and it works ok. I’ll try to make it work with your plugin entirely when i’ll have some spare time. Thanks for your time and your continuous feedback.

    jimbaldwin1137

    (@jimbaldwin1137yahoocom)

    I ma having a similar problem. After deleting entries in the database, they are still showing up when using the CDFB shortcode. It continues to display the entries which are no longer in the database. Has anyone resolved this issue?

    Plugin Author Michael Simpson

    (@msimpson)

    @jimbaldwin1137 I have seen this happen when there is a caching plugin installed in WordPress. Essentially a copy of the page gets cached, and when you go back to it, the old copy is shown instead of generating a fresh version of the page & running the short code.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Values don't update if they have been changed in database’ is closed to new replies.