WordPress.org

Ready to get started?Download WordPress

Forums

plugin admin side form submit (2 posts)

  1. Mohal
    Member
    Posted 2 years ago #

    Hi!

    Please, help!

    My plugin's admin side form needs to insert data into the database. Please note that my plugin has its own table (it is required). Now the scenario is like this:

    Admin side form code is in a function in my plugin primary file, usually the file which has same name as plugin. This function is attached with "add_submenu_page ()." When the sub menu is clicked... the form is displayed. Everything goes well by this stage. Now to insert the data... I made a new file (suppose: test1.php). I changed form's action attribute to: action="test1.php"... (test1.php is also in my plugin's folder. Note: Intentionally not writing complete path in action attribute here, in my code path is correct). All the data submitted from form do get to "test1.php"... I have checked it but I don't know for some reason... in "test1.php" I lost control over WordPress default functions. So, when I try to insert the data into the table like... wpdb->insert ()... it gives me error. When I var_dump ($wpdb)... it gave me "NULL."

    After two days of searching over internet and trying myself and finding no solution I am forced to post my problem here. Please help me! I hope someone has answer to my question.

    I think what I am trying to do is using multiple files for my plugin but what I don't get is why WordPress is not supporting it. If I am doing it wrong then please, help me!

    Thanx in advance!

    Regards!

  2. Big Bagel
    Member
    Posted 2 years ago #

    It's probably a minor error in your SQL statement. Use $wpdb->last_error to return the last error or $wpdb->print_error() to print the last error.

Topic Closed

This topic has been closed to new replies.

About this Topic