WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] How to Display and Update Data? (1 post)

  1. sanketzalak
    Member
    Posted 1 year ago #

    I am Newbie into WP So need some Help for Insert & Update into Default Database of WordPress.

    QUERY : 1

    I have 'contactdb' table into wp_mydb database which is default database. Also Installed the 'Contact Form 7 Plugin, Contact Form 7 Dynamic Text'

    In said table There are some fields in the 'contactdb'
    Field : ContactForm 7 IDs : Database Field Name
    (1) Id : "application-id" : app_id
    (2) First Name : "first-name" : f_name
    (3) Last Name : "last-name" : l_name
    (4) Status : "status" : c_status
    (2) Remarks : "remarks" : c_remarks

    Now when I click on Contact Form 7 above details should be inserted into database.

    What should I do for It?

    add_action('wpcf7_before_send_mail','save_to_db');
    function save_to_db($cf7) {
    //declare your varialbes, for example:
    $application_id = $cf7->posted_data["application-id"];
    $fitst_name = $cf7->posted_data["first-name"];
    $last_name = $cf7->posted_data["last-name"];
    $status_txt = $cf7->posted_data["status"];
    $remarks_txt = $cf7->posted_data["remarks"];

    $wpdb->insert('contactdb', array( 'application-id' => $_POST["$application_id"], 'first-name' => $_POST["$first_name"], 'last-name' => $_POST["$last_name"], 'status' => $_POST["$status_txt"], 'remarks' => $_POST["$remarks_txt"]), array( '%s', '%s', '%s','%s','%s' ) )

    }

    When I click on Submit Page just refresh and Dose not insert anything? Why?

    QUERY : 2

    How can I update Once I inserted it with above method?

    I use Exec-PHP Plugin to Display Code Result onto Page

Topic Closed

This topic has been closed to new replies.

About this Topic