How can I insert data back into a custom database using a form?

shanem November 29, 2012
Pinterest Stumbleupon Whatsapp

I just read the tutorial on working with custom database tables in WP. It was a very informative tutorial! My question is, was there ever a follow up regarding how to insert data back into your custom database using a form on a page while using WP?

Keep the tutorials coming!

The below tutorial was the one I was referring too.

Working With Custom Database Tables In WordPress Working With Custom Database Tables In WordPress Working With Custom Database Tables In WordPress A quick scan of the Best of WordPress Plugins page will reveal some of the many unique and niche ways you can make your blog work harder. What if you already have a database of... Read More

 

Ads by Google

  1. Muo TechGuy
    November 30, 2012 at 3:04 pm

    My bad, I can't find the follow up, if I wrote one.

    It's fairly simple though.

    1. Code a basic form
    2. Attach to submit with jquery, and use the AJAX method to post the data to a specified handler file
    3. in your handler.php, take the data, and use the wpdb->insert function to insert into the custom database, then send back a message for done or error.
    4. handle the return with a success or fail method.

    Here's a tutorial on posting form data with ajax: http://stackoverflow.com/questions/5004233/jquery-ajax-post-example

    Here's a brief overview of the wpdb class: http://wp.smashingmagazine.com/2011/09/21/interacting-with-the-wordpress-database/

    Scan down to the insert method, and just repalce the prefixed bit with the name of your table.

    • shane mc
      November 30, 2012 at 6:09 pm

      Hey Everyone,

      Thank you for all of your responses. I appreciate them all.

      I know how to make a form and insert data into a mysql database but what's confusing me is how to do it with WP. Muo TechGuy, I know you've outlined some helpful principles and links but if you or anyone could perhaps write a "step-by-step" tutorial for "dummies" that would be wonderful. Thanks for your consideration and help.

      Cheers!
      Shane

  2. Jesse Manalansan
    November 30, 2012 at 2:24 pm

    Google tutorials of how on inserting a data to mysql database using forms and php. :)

  3. Abba Jee
    November 30, 2012 at 11:29 am

    agree with you

  4. Abba Jee
    November 30, 2012 at 8:52 am

    I wonder if it's possible as well

    • Amit Sinha
      November 30, 2012 at 12:09 pm

      It is possible, the user must know php and MySQL and it is very easy. Well I didn't go step by step process the user must create html forms using action as php and send it to the server where an action is triggered to insert or update data in custom databases

Ads by Google